Static configuration
Configure Sockudo with TOML or JSON, understand environment precedence, and keep secrets out of static files.
This page explains exactly how Sockudo resolves its configuration at startup: which file it reads, how environment variables override it, and where secrets belong. Read it before writing a production config for any platform; the Linux, Docker, and Kubernetes guides all build on it.
Sockudo supports a static TOML file, a legacy-compatible JSON file, and runtime environment overrides. Use a file for the complete deployment shape. Use environment variables for the subset of settings that vary per environment and for secret references supplied by the platform.
Loading order
Configuration is resolved once, at startup, in this order:
- Start from compiled defaults.
- If
--config <path>(short form-c) is passed, load that file and nothing else. - Otherwise, look in the process working directory for
config/config.toml, thenconfig/config.json, and load the first one that exists. If neither exists, keep the compiled defaults. - Apply supported environment-variable overrides on top of the loaded values.
- Validate the final configuration.
An explicit .toml path is parsed as TOML. Any other filename extension is parsed as JSON. Prefer a
.toml or .json suffix so the format is obvious.
sockudo --config /etc/sockudo/config.tomlsockudo --config /etc/sockudo/config.jsonThe selected file becomes the complete file-based configuration. An explicit --config file is not
merged with an auto-discovered config/config.toml; fields missing from the file receive compiled
defaults, not values from another file.
Environment overrides behave differently: if applying them fails, Sockudo logs
environment variable overrides failed: <error> and continues starting. Alert on that log line.
Use --config in every production deployment. Relying on auto-discovery makes the result depend on
the working directory. The CONFIG_FILE environment variable present in the published container
image does not select the file by itself; the image’s default command passes an explicit
--config path.
Configuration is read only at startup. Change it through a rollout or service restart; there is no general-purpose hot reload.
Startup log lines
Once logging is initialized, Sockudo records which source it used. Expect one of these:
| Log message | Meaning |
|---|---|
explicit configuration applied: <path> | The --config file loaded. |
loaded configuration file: config/config.toml | Auto-discovery found a file (or config/config.json). |
no config/config.toml or config/config.json found; using defaults | No file was found; only defaults and environment variables apply. |
applied environment variable overrides | Environment overrides were applied. |
In production, require the explicit configuration applied line before sending traffic.
TOML or JSON?
| Format | Prefer it when | Notes |
|---|---|---|
| TOML | Humans maintain the file and comments are valuable. | Preferred for bare-metal, VM, and source deployments. |
| JSON | A chart, control plane, or program generates the file. | Useful for Helm configJson and legacy installations; comments are not allowed. |
| Environment only | A small, single-app deployment uses only supported overrides. | Not every nested policy has an environment equivalent. |
TOML and JSON deserialize into the same ServerOptions structure, so every key works in both.
The annotated reference file is config/config.toml in the repository.
Environment placeholders in config files
Before parsing, Sockudo replaces ${VAR} and ${VAR:-default} placeholders in the file with values
from the process environment. This lets a committed file reference a secret without containing it,
including nested values that have no dedicated environment variable:
[metrics]port = ${METRICS_PORT:-9601}
[[app_manager.array.apps]]id = "production"key = "${PROD_APP_KEY}"secret = "${PROD_APP_SECRET}"enabled = trueRules worth knowing:
- An environment variable that is set but empty is treated as unset, so
${VAR:-default}uses the default. - A placeholder without a default whose variable is unset fails the load and lists every unresolved variable in the error.
- Substitution is plain text over the whole file before parsing, including comments. A
${...}in a comment must also resolve. - The value is inserted verbatim. Quote placeholders for string fields, and avoid values containing
"or\in TOML or JSON strings, because they would change the file’s syntax.
Equivalent single-node files
This TOML profile keeps all state in one process and is suitable for a first production-like test, not for failover:
mode = "production"host = "0.0.0.0"port = 6001debug = falsemax_connections = 20000activity_timeout = 120shutdown_grace_period = 30
[adapter]driver = "local"
[cache]driver = "memory"
[queue]driver = "memory"
[rate_limiter]enabled = truedriver = "memory"
[metrics]enabled = truedriver = "prometheus"host = "0.0.0.0"port = 9601
[app_manager]driver = "memory"
[app_manager.array][[app_manager.array.apps]]id = "example"key = "replace-me"secret = "replace-me"enabled = true
[app_manager.array.apps.policy.limits]max_connections = 20000max_client_events_per_second = 100
[app_manager.array.apps.policy.features]enable_client_messages = falseenable_user_authentication = true
[app_manager.array.apps.policy.channels]allowed_origins = ["https://app.example.com"]The top-level max_connections caps sockets on this node across all apps (0 disables the cap).
The app’s policy.limits.max_connections is a separate per-app quota.
The equivalent JSON is:
{ "mode": "production", "host": "0.0.0.0", "port": 6001, "debug": false, "max_connections": 20000, "activity_timeout": 120, "shutdown_grace_period": 30, "adapter": { "driver": "local" }, "cache": { "driver": "memory" }, "queue": { "driver": "memory" }, "rate_limiter": { "enabled": true, "driver": "memory" }, "metrics": { "enabled": true, "driver": "prometheus", "host": "0.0.0.0", "port": 9601 }, "app_manager": { "driver": "memory", "array": { "apps": [ { "id": "example", "key": "replace-me", "secret": "replace-me", "enabled": true, "policy": { "limits": { "max_connections": 20000, "max_client_events_per_second": 100 }, "features": { "enable_client_messages": false, "enable_user_authentication": true }, "channels": { "allowed_origins": ["https://app.example.com"] } } } ] } }}Replace the example credentials before use. For a committed production file, replace the literal
key and secret with ${...} placeholders, bootstrap the app from a secret-backed environment, or
use a persistent app manager.
Clustered Redis profile
The stable structure can remain in TOML:
mode = "production"host = "0.0.0.0"port = 6001max_connections = 50000shutdown_grace_period = 30
[adapter]driver = "redis"# Fail startup instead of silently running as an isolated local node.fallback_to_local = false
[cache]driver = "redis"
[queue]driver = "redis"
[rate_limiter]enabled = truedriver = "redis"
[app_manager]driver = "memory"
[metrics]enabled = truehost = "0.0.0.0"port = 9601fallback_to_local defaults to true. Leaving it on lets a node that cannot reach Redis at startup
run alone, splitting clients into groups that never see each other’s events.
Inject the shared address, node identity, and one immutable app at runtime:
REDIS_URL=rediss://sockudo@redis.internal:6379/0INSTANCE_PROCESS_ID=sockudo-a-01SOCKUDO_DEFAULT_APP_ENABLED=trueSOCKUDO_DEFAULT_APP_ID=productionSOCKUDO_DEFAULT_APP_KEY=secret-store-valueSOCKUDO_DEFAULT_APP_SECRET=secret-store-valueSOCKUDO_DEFAULT_APP_ALLOWED_ORIGINS=https://app.example.comSOCKUDO_DEFAULT_APP_MAX_CONNECTIONS=50000REDIS_URL updates the Redis adapter, cache, queue, and rate limiter connection. Driver selection
still must be redis, either in the file or through ADAPTER_DRIVER, CACHE_DRIVER,
QUEUE_DRIVER, and RATE_LIMITER_DRIVER.
INSTANCE_PROCESS_ID names the node. When it is unset, Sockudo generates a random UUID at every
start, which is unique but changes on each restart. Set it explicitly when logs, metrics, or Iggy
consumers need a stable identity, and never put one shared value in a file that every replica
loads.
Use a persistent app manager instead of environment bootstrap when operators create, rotate, or disable multiple applications without rebuilding the deployment.
What belongs where
| Setting | Static file | Environment | Secret store |
|---|---|---|---|
| Driver selection and feature gates | Yes | Optional rollout override | No |
| Nested app/channel policy | Yes, or persistent app manager | Only the documented subset | Credentials only |
| Retention, buffer, and queue reliability | Yes | Use supported overrides sparingly | No |
| Per-environment hostnames and ports | Template, generated file, or ${VAR} placeholder | Yes | Only if address contains credentials |
| App keys and secrets | Avoid literals in committed files; use ${VAR} placeholders | Inject from secret reference | Yes |
| Redis, SQL, broker passwords | Avoid literals | Inject from secret reference | Yes |
| TLS private keys and push provider keys | File path or credential reference | Path/reference only | Yes |
Do not place secrets in image layers, Helm values committed to Git, Kubernetes ConfigMaps, process arguments, or Terraform plan output.
Environment override behavior
Environment variables are explicit mappings in the Sockudo configuration loader, not a generic
SECTION_FIELD=value translation. The environment variable reference
is the authoritative list. An unknown variable name is ignored without a warning, so check spelling
against the reference.
Several app-bootstrap variables have deliberate replacement behavior:
- a complete
SOCKUDO_DEFAULT_APP_ID,SOCKUDO_DEFAULT_APP_KEY, andSOCKUDO_DEFAULT_APP_SECRETset registers the environment-backed default app - setting any of those three, or
SOCKUDO_DEFAULT_APP_ENABLED=false, removes the apps declared inline in the file SOCKUDO_DEFAULT_APP_ENABLED=falsedisables the environment-backed registration- a partial set (for example an ID and key without a secret) registers nothing and logs
default app env configured but id, key, and secret were not all provided SOCKUDO_SKIP_INLINE_APPS=trueskips apps declared inside the fileAPP_MANAGER_REGISTER_INLINE_APPS=falsealso prevents inline registration
Avoid mixing an inline app and environment bootstrap accidentally. Choose one source for each app and confirm the startup messages.
Container and Kubernetes mounts
Mount a read-only file into the published container and replace the default command:
docker run --rm \ --mount type=bind,src="$PWD/config.toml",dst=/app/config/production.toml,readonly \ ghcr.io/sockudo/sockudo:5.3.0 \ sockudo --config /app/config/production.tomlIn Kubernetes, mount non-secret structure from a ConfigMap and inject secrets separately:
containers: - name: sockudo args: ["--config", "/etc/sockudo/config.toml"] envFrom: - secretRef: name: sockudo-runtime volumeMounts: - name: config mountPath: /etc/sockudo readOnly: truevolumes: - name: config configMap: name: sockudo-configWith ${VAR} placeholders in the ConfigMap, the Secret supplies the values and the ConfigMap stays
safe to commit. The Helm chart also accepts configJson for advanced generated configuration and
extraEnvFrom for Secret or ConfigMap references; see Kubernetes and Helm.
Validate before rollout
-
Check syntax in CI so a typo never reaches a host:
Terminal window taplo check config.tomljq empty config.jsonBoth commands print nothing and exit
0when the file parses. -
Start the exact production binary with the same features, environment, working directory, and mounted secrets:
Terminal window sockudo --config /etc/sockudo/config.tomlThe process must keep running. The logs must contain
explicit configuration appliedandapplied environment variable overrides, and must not containenvironment variable overrides failedorConfiguration validation failed. -
Check the process and app health from the same host:
Terminal window curl -fsS -o /dev/null -w '%{http_code}\n' http://127.0.0.1:6001/livecurl -fsS http://127.0.0.1:6001/up/<app-id>Expect
200from/live./up/<app-id>printsOKonce shared dependencies are reachable,DEGRADED(still200) when a non-critical check reports degradation, and fails with503or404when a dependency is down or the app does not exist.