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"
| Field | Type | Default | Environment Variable |
|---|
log_level | String | "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"
| Field | Type | Required | Environment Variable |
|---|
master_key | String | Yes | SECRETS_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"
| Field | Type | Required | Default | Environment Variable |
|---|
bot_token | String | Yes | - | DISCORD_TOKEN |
client_id | String | Yes | - | DISCORD_CLIENT_ID |
client_secret | String | Yes | - | DISCORD_CLIENT_SECRET |
redirect_uri | String | No | "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
| Field | Type | Default | Environment Variable |
|---|
url | String | "postgres://user:pass@localhost:5433/flora" | DATABASE_URL |
max_connections | u32 | 5 | DATABASE_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
| Field | Type | Default | Environment Variable |
|---|
url | String | "redis://127.0.0.1:5434/0" | CACHE_URL |
pool_size | usize | 10 | CACHE_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
| Field | Type | Default | Max | Environment Variable |
|---|
max_workers | usize | 4 | 64 | RUNTIME_MAX_WORKERS |
boot_timeout_secs | u64 | 5 | - | RUNTIME_BOOT_TIMEOUT_SECS |
load_timeout_secs | u64 | 30 | - | RUNTIME_LOAD_TIMEOUT_SECS |
dispatch_timeout_secs | u64 | 3 | - | RUNTIME_DISPATCH_TIMEOUT_SECS |
max_script_bytes | usize | 8388608 (8MB) | - | RUNTIME_MAX_SCRIPT_BYTES |
max_bundle_files | usize | 200 | - | RUNTIME_MAX_BUNDLE_FILES |
max_bundle_total_bytes | usize | 1048576 (1MB) | - | RUNTIME_MAX_BUNDLE_TOTAL_BYTES |
max_cron_jobs | usize | 32 | - | RUNTIME_MAX_CRON_JOBS |
cron_timeout_secs | u64 | 5 | - | RUNTIME_CRON_TIMEOUT_SECS |
migration_timeout_ms | u64 | 500 | - | 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
| Field | Type | Required | Default | Environment Variable |
|---|
port | u16 | No | 3000 | API_PORT |
address | IpAddr | No | "0.0.0.0" | API_ADDRESS |
secret | String | Yes | - | API_SECRET |
cookie_ttl_secs | u64 | No | 2592000 (30 days) | API_COOKIE_TTL_SECS |
cookie_secure | bool | No | false | API_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"
| Field | Type | Required | Default | Environment Variable |
|---|
url | String | No | "http://localhost:3001" | BUILD_SERVICE_URL |
secret | String | Yes | - | 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"
# Use environment variables for sensitive values
export DATABASE_URL="postgres://user:pass@prod-db:5432/flora"
export CACHE_URL="redis://prod-redis:6379/0"
export DISCORD_TOKEN="your-bot-token"
export SECRETS_MASTER_KEY="your-64-char-hex-string"
export API_SECRET="your-api-secret"
export API_COOKIE_SECURE="true"
# Scale workers based on load
export RUNTIME_MAX_WORKERS="8"
# Run runtime
./x run-release
Configuration Loading
The runtime loads configuration in this order (from apps/runtime/src/main.rs:40):
- Load environment variables from
.env file (via dotenvy)
- Merge values from
config.toml
- Apply environment variable overrides
- Validate required fields
Never commit .env or config.toml files containing secrets to version control.