Configuration Reference
Everything you can set in the configuration file, the environment, or on the command line.
Config file
By default the server looks for config.toml in the working directory. Pass a different path with --config <path>. The file is read once at startup; restart the process after changing it.
Options
| Key | Type | Default | Description |
|---|---|---|---|
server.hostoptional |
string | "127.0.0.1" |
Address to bind. Use "0.0.0.0" to accept connections from other machines. |
server.portoptional |
integer | 8080 |
TCP port to listen on. Must be between 1 and 65535. |
server.workersoptional |
integer | CPU count | Number of worker threads handling requests. |
database.urlrequired |
string | none | Connection URL, for example postgres://user:pass@host/db. |
database.max_connectionsoptional |
integer | 10 |
Upper bound on pooled connections per worker. |
log.leveloptional |
string | "info" |
One of debug, info, warn, error. |
log.formatoptional |
string | "text" |
"text" for humans, "json" for log aggregators. |
cache.ttl_secondsoptional |
integer | 300 |
How long responses are cached. Set to 0 to disable caching. |
Environment variables
Every key can be overridden with an environment variable. Replace dots with underscores and prefix with APP_, so server.port becomes APP_SERVER_PORT. Values from the environment always win over the file.
Precedence
Settings are resolved in this order, highest first:
- Command-line flags
- Environment variables
- The config file
- Built-in defaults
Secrets. Do not commit
database.url with a password to version control. Put it in APP_DATABASE_URL instead.
Example
# config.toml
[server]
host = "0.0.0.0"
port = 8080
workers = 4
[database]
url = "postgres://app@db.internal/app"
max_connections = 20
[log]
level = "info"
format = "json"
[cache]
ttl_seconds = 600
Validate a file without starting the server:
$ app config check --config config.toml
config.toml: ok