Skip to content

Environment Variables

⚠️ BREAKING CHANGE — Tina4 v3.12.0

Every framework env var now requires the TINA4_ prefix. The legacy un-prefixed names (DATABASE_URL, SECRET, SMTP_HOST, HOST_NAME, etc.) no longer work. Setting them at startup makes the framework refuse to boot with a list of renames.

Run tina4 env --migrate to rewrite your existing .env automatically, or rename manually using the table below. The runtime guard prints the same mapping if it detects legacy names.

Conventional names stay un-prefixed: PORT, HOST, NODE_ENV, RACK_ENV, RUBY_ENV, ENVIRONMENT. These are runtime/PaaS conventions, not framework config.

Tina4 Ruby is configured through environment variables, read from .env at the project root. Every variable has a sensible default — most projects set three or four values and leave the rest alone.

This chapter lists every variable the Ruby framework reads, grouped by subsystem. Start with the minimum-config examples at the end, then come back here when you need to tune something specific.


Core Server

VariableDefaultDescription
HOST0.0.0.0Bind address. 0.0.0.0 listens on every interface. 127.0.0.1 restricts to localhost.
TINA4_HOST(inherits HOST)Tina4-specific alias for HOST.
PORT7147HTTP server port. The Rust CLI prefers TINA4_PORT but falls back to PORT.
TINA4_PORT(inherits PORT)Explicit Tina4-specific port override. Takes precedence over PORT when both are set.
TINA4_HOST_NAMElocalhost:7147Fully-qualified host used in generated absolute URLs (Swagger, OAuth redirects, emails).
TINA4_DEBUGfalseMaster debug toggle. Enables Swagger UI, dev dashboard, live reload, template dump filter, error overlay. Never set to true in production.
TINA4_ENVdevelopmentRuntime environment label. Values like development, staging, production control dev-only features. Falls back to RACK_ENV then RUBY_ENV.
RACK_ENV(none)Rack-standard environment label. Used if TINA4_ENV is unset.
RUBY_ENV(none)Ruby-ecosystem environment label. Used if TINA4_ENV and RACK_ENV are unset.
TINA4_NO_BROWSERfalseStops tina4 serve from opening your browser on every restart. Recommended during active development.
TINA4_NO_RELOADfalseDisables the dev hot-reload signal from the Rust CLI. Use when you want a stable server for debugging.
ENVIRONMENT(none)PaaS-style environment label. Read by tooling alongside RACK_ENV/RUBY_ENV.
TINA4_SHUTDOWN_TIMEOUT10Seconds the supervisor waits for graceful shutdown before terminating workers.
TINA4_SUPERVISOR_URL(derived from TINA4_PORT + 2000)Override URL for the local Rust CLI supervisor used by the dev dashboard.
TINA4_TEMPLATE_ROUTINGonControls automatic template-to-route binding. Set to off, false, 0, no, or disabled to require explicit route declarations.
TINA4_ALLOW_LEGACY_ENVfalseBypass the v3.12 legacy-env startup guard. Intended for CI/migration scripts only.
TINA4_SUPPRESSfalseSuppresses the startup banner. Useful for headless processes and CI runs.
TINA4_ENV_FILE.envPath or filename of the dotenv file loaded at boot. Resolved against the project root when relative.
TINA4_HEALTH_PATH/__healthHealth-check route mounted by Tina4::Health. The legacy /health path stays registered as an alias unless it's the configured value.

Routing

VariableDefaultDescription
TINA4_TRAILING_SLASH_REDIRECTfalseWhen truthy, the Rack app issues a 301 redirect that strips trailing slashes from request paths.

Secrets and Authentication

VariableDefaultDescription
TINA4_SECRETtina4-default-secretJWT signing secret. Must be long, random, and unique per environment. Never commit.
TINA4_TOKEN_LIMIT60JWT token lifetime in minutes.
TINA4_JWT_ALGORITHMHS256JWT signing algorithm.
TINA4_API_KEY(empty)Static API key used by Tina4::Auth.validate_api_key as a fallback to JWT.
TINA4_API_KEY(empty)Legacy alias for TINA4_API_KEY.

Database

VariableDefaultDescription
TINA4_DATABASE_URL(required for non-SQLite)Connection URL. Scheme selects the driver: sqlite, postgres, mysql, firebird.
TINA4_DATABASE_USERNAME(empty)Overrides the username embedded in TINA4_DATABASE_URL.
TINA4_DATABASE_PASSWORD(empty)Overrides the password embedded in TINA4_DATABASE_URL.
TINA4_DATABASE_FIREBIRD_PATH(empty)Overrides the database path/alias parsed from TINA4_DATABASE_URL for Firebird. Useful for Windows backslash paths and split-config setups.
TINA4_DATABASE_URL(empty)Legacy alias for TINA4_DATABASE_URL.
TINA4_AUTOCOMMITfalseAuto-commit after every write. Default is off — call commit explicitly.
TINA4_DB_CACHEfalseEnables in-memory query-result caching for read queries.
TINA4_DB_CACHE_TTL30Query cache TTL in seconds when TINA4_DB_CACHE=true.
TINA4_ORM_PLURAL_TABLE_NAMEStrueWhen true, the ORM pluralises class names into table names (Userusers). Set false to keep them singular.
TINA4_DB_POOL0Connection pool size used by Tina4::Database.new(url, pool:) when the caller doesn't pass pool: explicitly. 0 disables pooling.

CORS

VariableDefaultDescription
TINA4_CORS_ORIGINS*Comma-separated allowed origins. Lock down to real domains in production.
TINA4_CORS_METHODSGET, POST, PUT, PATCH, DELETE, OPTIONSAllowed request methods.
TINA4_CORS_HEADERSContent-Type,Authorization,X-Request-IDAllowed request headers.
TINA4_CORS_CREDENTIALSfalseSend Access-Control-Allow-Credentials: true.
TINA4_CORS_MAX_AGE86400Preflight cache lifetime in seconds.

Security Headers

VariableDefaultDescription
TINA4_CSPdefault-src 'self'Content-Security-Policy header.
TINA4_CSRFfalseCSRF token validation on POST/PUT/PATCH/DELETE. Off by default in Ruby; enable with true.
TINA4_HSTS(empty/off)Strict-Transport-Security max-age in seconds. Set 31536000 in production with HTTPS.
TINA4_FRAME_OPTIONSSAMEORIGINX-Frame-Options header.
TINA4_REFERRER_POLICYstrict-origin-when-cross-originReferrer-Policy header.
TINA4_PERMISSIONS_POLICYcamera=(), microphone=(), geolocation=()Permissions-Policy header.

Rate Limiting

VariableDefaultDescription
TINA4_RATE_LIMIT100Maximum requests per window per IP. Set 0 to disable.
TINA4_RATE_WINDOW60Rate-limit window in seconds.

Sessions

VariableDefaultDescription
TINA4_SESSION_BACKENDfileStorage backend. Options: file, redis, valkey, mongo, database.
TINA4_SESSION_TTL3600Session expiry in seconds.
TINA4_SESSION_SAMESITELaxSameSite cookie attribute. Options: Strict, Lax, None.
TINA4_SESSION_PATHdata/sessionsFilesystem path for the file backend.
TINA4_SESSION_NAMEtina4_sessionSession cookie name. Used unless the caller passes an explicit cookie_name.
TINA4_SESSION_HTTPONLYtrueSets the HttpOnly attribute on the session cookie. Set false to allow JavaScript access.
TINA4_SESSION_SECUREfalseSets the Secure attribute on the session cookie. Enable in production behind HTTPS.

Valkey/Redis session backend

VariableDefaultDescription
TINA4_SESSION_VALKEY_HOSTlocalhostValkey/Redis host for the session handler.
TINA4_SESSION_VALKEY_PORT6379Valkey/Redis port.
TINA4_SESSION_VALKEY_PASSWORD(none)Valkey/Redis auth password.
TINA4_SESSION_VALKEY_DB0Valkey/Redis database number.
TINA4_SESSION_VALKEY_PREFIXtina4:session:Key prefix used for session entries.
TINA4_SESSION_VALKEY_TTL86400Per-key expiry in seconds.

Cache

VariableDefaultDescription
TINA4_CACHE_BACKENDmemoryResponse cache backend. Options: memory, file, redis.
TINA4_CACHE_DIRdata/cacheCache directory for the file backend.
TINA4_CACHE_TTL0Default cache TTL in seconds (0 disables caching for the global instance; the singleton helper uses 60 when unset).
TINA4_CACHE_MAX_ENTRIES1000Maximum cache entries before eviction.
TINA4_CACHE_URLredis://localhost:6379Connection URL for the Redis backend.

Templates

VariableDefaultDescription
TINA4_TEMPLATE_CACHE_TTL0Frond template cache TTL in seconds. 0 keeps compiled templates cached permanently; positive values expire entries after N seconds.

GraphQL

VariableDefaultDescription
TINA4_GRAPHQL_AUTO_SCHEMAtrueWhen true, the GraphQL module auto-generates a schema from registered ORM models. Set false to require an explicit schema.
TINA4_GRAPHQL_ENDPOINT/graphqlPath the GraphQL handler is mounted at when the caller doesn't pass an explicit path.

Queues

VariableDefaultDescription
TINA4_QUEUE_BACKENDfileQueue backend. Options: file, kafka, rabbitmq, mongo, database.
TINA4_QUEUE_URL(none)Connection URL for remote backends. Parsed for host/port when set.

Kafka queue backend

VariableDefaultDescription
TINA4_KAFKA_BROKERS(none)Comma-separated broker list (e.g. localhost:9092).
TINA4_KAFKA_GROUP_IDtina4_consumer_groupKafka consumer group ID.

RabbitMQ queue backend

VariableDefaultDescription
TINA4_RABBITMQ_HOSTlocalhostRabbitMQ host.
TINA4_RABBITMQ_PORT5672RabbitMQ port.
TINA4_RABBITMQ_USERNAMEguestRabbitMQ username.
TINA4_RABBITMQ_PASSWORDguestRabbitMQ password.
TINA4_RABBITMQ_VHOST/RabbitMQ virtual host.

MongoDB queue backend

VariableDefaultDescription
TINA4_MONGO_URI(none)Full MongoDB connection string. Overrides host/port when set.
TINA4_MONGO_HOSTlocalhostMongoDB host.
TINA4_MONGO_PORT27017MongoDB port.
TINA4_MONGO_USERNAME(none)MongoDB username.
TINA4_MONGO_PASSWORD(none)MongoDB password.
TINA4_MONGO_DBtina4MongoDB database name.
TINA4_MONGO_COLLECTIONtina4_queueMongoDB collection name for jobs.

WebSocket

VariableDefaultDescription
TINA4_WS_BACKPLANE(none)Backplane type. Options: redis, nats. Required for multi-instance broadcasts.
TINA4_WS_BACKPLANE_URLredis://localhost:6379 (Redis) / nats://localhost:4222 (NATS)Connection URL for the chosen backplane.

Email

VariableDefaultDescription
TINA4_MAIL_HOSTlocalhostSMTP server hostname.
TINA4_MAIL_PORT587SMTP server port.
TINA4_MAIL_USERNAME(none)SMTP authentication username.
TINA4_MAIL_PASSWORD(none)SMTP authentication password.
TINA4_MAIL_FROMdev@localhostDefault sender email address.
TINA4_MAIL_FROM_NAME(empty)Default sender display name.
TINA4_MAIL_ENCRYPTIONtlsConnection encryption. Options: tls, ssl, none.
TINA4_MAIL_IMAP_HOST(inherits mail host)IMAP server for inbound mail.
TINA4_MAIL_IMAP_PORT993IMAP server port.
TINA4_MAIL_IMAP_USERNAME(inherits SMTP username)IMAP authentication username. Mapped from legacy IMAP_USER.
TINA4_MAIL_IMAP_PASSWORD(inherits SMTP password)IMAP authentication password. Mapped from legacy IMAP_PASS.
TINA4_MAIL_IMAP_ENCRYPTIONtlsIMAP connection encryption. Accepts tls, starttls, or none.
TINA4_MAILBOX_DIRdata/mailboxDev mailbox directory. All outbound mail lands here when TINA4_DEBUG=true.

TINA4_MAIL_HOST, TINA4_MAIL_PORT, TINA4_MAIL_USERNAME, TINA4_MAIL_PASSWORD, TINA4_MAIL_FROM, TINA4_MAIL_FROM_NAME, TINA4_MAIL_IMAP_HOST, TINA4_MAIL_IMAP_PORT are accepted as legacy aliases. New projects should use the TINA4_MAIL_* names.


Logging

VariableDefaultDescription
TINA4_LOG_LEVEL[TINA4_LOG_ALL]Console log level. Options: [TINA4_LOG_ALL], [TINA4_LOG_DEBUG], [TINA4_LOG_INFO], [TINA4_LOG_WARNING], [TINA4_LOG_ERROR], [TINA4_LOG_NONE]. Also accepts plain DEBUG, INFO, ERROR, etc.
TINA4_LOG_MAX_SIZE10Per-file log size limit in megabytes. Rotated when exceeded.
TINA4_LOG_KEEP5Number of rotated log files to retain.

Logs default to stdout. Set TINA4_LOG_OUTPUT=file plus TINA4_LOG_FILE=app.log to write to disk; Ruby's stdlib Logger rotates at TINA4_LOG_ROTATE_SIZE bytes and keeps TINA4_LOG_ROTATE_KEEP backups natively.

VariableDefaultDescription
TINA4_LOG_FILE(empty = stdout only)Explicit log file path. Absolute, or resolved relative to TINA4_LOG_DIR.
TINA4_LOG_DIRlogsDirectory used when TINA4_LOG_FILE is set without an absolute path.
TINA4_LOG_FORMATtextLog line format. Accepts text or json.
TINA4_LOG_OUTPUTstdoutOutput sink. Accepts stdout, file, or both.
TINA4_LOG_CRITICALfalseWhen true, gates the new critical level and raises on log write failures instead of swallowing them.
TINA4_LOG_ROTATE_SIZE10485760Per-file rotation threshold in bytes (10 MB). 0 disables rotation. Handled natively by stdlib Logger.new(path, shift_age, shift_size).
TINA4_LOG_ROTATE_KEEP5Number of rotated backups to retain.

Uploads

VariableDefaultDescription
TINA4_MAX_UPLOAD_SIZE10485760Maximum multipart upload size in bytes (10 MB). Requests larger than this are rejected before parsing.

Services (background tasks)

VariableDefaultDescription
TINA4_SERVICE_DIRsrc/servicesDirectory scanned for service classes.
TINA4_SERVICE_SLEEP5Seconds the service runner sleeps between iterations.

Localisation

VariableDefaultDescription
TINA4_LOCALEenDefault locale for Tina4::Localization.
TINA4_LOCALE_DIRsrc/localeDirectory containing locale JSON files.

AI and MCP Tooling

The dashboard AI chat and the framework's RAG-based code search both default to a local qwen2.5-coder model served via Ollama. Nothing leaves your machine unless you point TINA4_AI_URL at a remote endpoint.

VariableDefaultDescription
TINA4_AI_URLhttp://localhost:11434OpenAI-compatible HTTP endpoint for the chat/completion model (Ollama by default).
TINA4_AI_MODELqwen2.5-coderModel identifier the endpoint should serve.
TINA4_RAG_URL(inherits TINA4_AI_URL)Embedding endpoint for the framework RAG index.
TINA4_AI_MODELnomic-embed-textEmbedding model used to index the framework and src/.
TINA4_MCP_REMOTEfalseAllow the MCP server to bind on non-localhost interfaces. Never enable in production.
TINA4_NO_AI_PORTfalseDisables the MCP port listener in dev mode.
TINA4_OVERRIDE_CLIENTfalseAllow the framework to start without the Rust CLI (tina4 serve). Used in Docker images and CI runners; bypasses SCSS compilation, the file watcher, and live reload.

MCP

VariableDefaultDescription
TINA4_MCP(inherits TINA4_DEBUG)Enables the MCP server. Defaults to whatever TINA4_DEBUG is set to; pass true/false to override explicitly.
TINA4_MCP_PORT(derived from TINA4_PORT + 2000)Port the MCP server binds to. Defaults to the HTTP port plus 2000.

Swagger / OpenAPI

VariableDefaultDescription
TINA4_SWAGGER_TITLETina4 APIOpenAPI spec title. Falls back to PROJECT_NAME.
TINA4_SWAGGER_DESCRIPTIONAuto-generated API documentationOpenAPI spec description.
TINA4_SWAGGER_VERSION(Gem version)Overrides the spec version.
TINA4_SWAGGER_ENABLED(inherits TINA4_DEBUG)Enables the Swagger UI and /swagger.json route. Defaults to TINA4_DEBUG; set explicitly to override.
TINA4_SWAGGER_CONTACT_EMAIL(empty)Contact email rendered into the OpenAPI info.contact block.
TINA4_SWAGGER_LICENSE(empty)SPDX license name (e.g. MIT) rendered into the OpenAPI info.license block.
PROJECT_NAME(none)Alternative OpenAPI title source when TINA4_SWAGGER_TITLE is unset.

Minimal .env for Development

bash
TINA4_DEBUG=true
TINA4_LOG_LEVEL=ALL
TINA4_NO_BROWSER=true

Debug mode lights up the Swagger UI, the dev dashboard, detailed error pages, and live reload. Keeping the browser flag on stops a new tab opening every time you save a file.


Minimal .env for Production

bash
TINA4_SECRET=your-long-random-secret-here
TINA4_DATABASE_URL=postgresql://user:password@db-host:5432/myapp
TINA4_CORS_ORIGINS=https://myapp.com,https://www.myapp.com
TINA4_HSTS=31536000
TINA4_MAIL_HOST=smtp.example.com
TINA4_MAIL_PORT=587
TINA4_MAIL_USERNAME=noreply@myapp.com
TINA4_MAIL_PASSWORD=your-smtp-password
TINA4_MAIL_FROM=noreply@myapp.com

No TINA4_DEBUG. It defaults to false, which is what you want in production. Set a real secret, a real database, locked-down CORS origins, HSTS, and SMTP credentials if you send email. Everything else has a production-appropriate default.

Sponsored with 🩵 by Code InfinityCode Infinity