Skip to main content

Overview

The flora runtime is configured via config.toml and environment variables. All configuration values can be overridden by their corresponding environment variable.
Copy config.template.toml to config.toml to get started. Required values must be set before the runtime can start.

Configuration Structure

Configuration is managed by the flora_config crate using the confique library. Environment variables always take precedence over config.toml values, which take precedence over defaults. Source: crates/flora_config/src/lib.rs:1

Logging

log_level = "flora::runtime=info,flora=info"
FieldTypeDefaultEnvironment Variable
log_levelString"flora::runtime=info,flora=info"RUST_LOG
Uses the same format as RUST_LOG. Controls tracing output for all runtime components.

Secrets

[secrets]
master_key = "your-64-char-hex-string"
FieldTypeRequiredEnvironment Variable
master_keyStringYesSECRETS_MASTER_KEY
32-byte key (64 hex characters) for encrypting stored secrets and deriving placeholders. This value must be set for the runtime to start. Source: crates/flora_config/src/lib.rs:136

Discord

[discord]
bot_token = "your-discord-bot-token"
client_id = "your-discord-client-id"
client_secret = "your-discord-client-secret"
redirect_uri = "http://localhost:3000/auth/callback"
FieldTypeRequiredDefaultEnvironment Variable
bot_tokenStringYes-DISCORD_TOKEN
client_idStringYes-DISCORD_CLIENT_ID
client_secretStringYes-DISCORD_CLIENT_SECRET
redirect_uriStringNo"http://localhost:3000/auth/callback"DISCORD_REDIRECT_URI
Discord bot credentials and OAuth configuration. The redirect URI must match the one configured in the Discord developer portal. Source: crates/flora_config/src/lib.rs:34

Database (PostgreSQL)

[database]
url = "postgres://user:pass@localhost:5433/flora"
max_connections = 5
FieldTypeDefaultEnvironment Variable
urlString"postgres://user:pass@localhost:5433/flora"DATABASE_URL
max_connectionsu325DATABASE_MAX_CONNECTIONS
PostgreSQL connection configuration. The database stores deployments, tokens, KV store metadata, and secrets.
Run ./dev.sh from the repository root to start PostgreSQL on port 5433.
Source: crates/flora_config/src/lib.rs:54

Cache (Redis/Valkey)

[cache]
url = "redis://127.0.0.1:5434/0"
pool_size = 10
FieldTypeDefaultEnvironment Variable
urlString"redis://127.0.0.1:5434/0"CACHE_URL
pool_sizeusize10CACHE_POOL_SIZE
Redis/Valkey configuration for session storage and caching. The runtime uses exponential backoff reconnection (100ms to 30s). Source: crates/flora_config/src/lib.rs:68

Runtime

[runtime]
max_workers = 4
boot_timeout_secs = 5
load_timeout_secs = 30
dispatch_timeout_secs = 3
max_script_bytes = 8388608
max_bundle_files = 200
max_bundle_total_bytes = 1048576
max_cron_jobs = 32
cron_timeout_secs = 5
migration_timeout_ms = 500
FieldTypeDefaultMaxEnvironment Variable
max_workersusize464RUNTIME_MAX_WORKERS
boot_timeout_secsu645-RUNTIME_BOOT_TIMEOUT_SECS
load_timeout_secsu6430-RUNTIME_LOAD_TIMEOUT_SECS
dispatch_timeout_secsu643-RUNTIME_DISPATCH_TIMEOUT_SECS
max_script_bytesusize8388608 (8MB)-RUNTIME_MAX_SCRIPT_BYTES
max_bundle_filesusize200-RUNTIME_MAX_BUNDLE_FILES
max_bundle_total_bytesusize1048576 (1MB)-RUNTIME_MAX_BUNDLE_TOTAL_BYTES
max_cron_jobsusize32-RUNTIME_MAX_CRON_JOBS
cron_timeout_secsu645-RUNTIME_CRON_TIMEOUT_SECS
migration_timeout_msu64500-RUNTIME_MIGRATION_TIMEOUT_MS

Worker Configuration

  • max_workers: Number of worker threads for guild isolates. Clamped between 1 and 64. Each worker can host multiple guild runtimes.

Timeout Configuration

  • boot_timeout_secs: Timeout for runtime bootstrap. Set to 0 to disable.
  • load_timeout_secs: Timeout for script/module loading. Set to 0 to disable.
  • dispatch_timeout_secs: Timeout per Discord event dispatch. Set to 0 to disable.
  • cron_timeout_secs: Timeout for cron handler execution. Set to 0 to disable.
  • migration_timeout_ms: Timeout for migration quiesce phase. Set to 0 to disable.

Size Limits

  • max_script_bytes: Maximum combined size of SDK + deployment bundle (default 8MB).
  • max_bundle_files: Maximum number of files in a deployment bundle.
  • max_bundle_total_bytes: Maximum total size of deployment source files (default 1MB).

Cron Limits

  • max_cron_jobs: Maximum number of cron jobs per guild.
Source: crates/flora_config/src/lib.rs:79

API Server

[api]
port = 3000
address = "0.0.0.0"
secret = "your-api-secret-key"
cookie_ttl_secs = 2592000
cookie_secure = false
FieldTypeRequiredDefaultEnvironment Variable
portu16No3000API_PORT
addressIpAddrNo"0.0.0.0"API_ADDRESS
secretStringYes-API_SECRET
cookie_ttl_secsu64No2592000 (30 days)API_COOKIE_TTL_SECS
cookie_secureboolNofalseAPI_COOKIE_SECURE
HTTP API server configuration. The API is used by the CLI for deployments, logs, KV operations, and authentication.
  • secret: Secret key for signing cookies. This value must be set.
  • cookie_secure: Set to true in production when using HTTPS.
Source: crates/flora_config/src/lib.rs:116

Build Service

[build_service]
url = "http://localhost:3001"
secret = "shared-build-service-secret"
FieldTypeRequiredDefaultEnvironment Variable
urlStringNo"http://localhost:3001"BUILD_SERVICE_URL
secretStringYes-BUILD_SERVICE_SECRET
Internal build service configuration for server-side bundling. The shared secret authenticates requests between the runtime and build service. Source: crates/flora_config/src/lib.rs:145

Environment-Specific Configuration

# Start PostgreSQL and Redis
./dev.sh

# Use default config values
cp config.template.toml config.toml

# Set required values in config.toml or via environment:
export DISCORD_TOKEN="your-bot-token"
export DISCORD_CLIENT_ID="your-client-id"
export DISCORD_CLIENT_SECRET="your-client-secret"
export SECRETS_MASTER_KEY="your-64-char-hex-string"
export API_SECRET="your-api-secret"
export BUILD_SERVICE_SECRET="your-build-secret"

Configuration Loading

The runtime loads configuration in this order (from apps/runtime/src/main.rs:40):
  1. Load environment variables from .env file (via dotenvy)
  2. Merge values from config.toml
  3. Apply environment variable overrides
  4. Validate required fields
Never commit .env or config.toml files containing secrets to version control.

Build docs developers (and LLMs) love