Skip to content

Configuration

DagNats uses a three-tier configuration system where each tier overrides the previous.

Resolution Order

  1. Built-in defaults – hardcoded, platform-appropriate values
  2. Config file (dagnats.yaml) – optional file in the working directory
  3. Environment variables (DAGNATS_*) – highest priority

Zero-config starts everything on defaults. Environment variables always win.

Config Keys

KeyTypeDefault (macOS)Default (Linux)
data_dirstring~/Library/Application Support/dagnats~/.local/share/dagnats
http_addrstring:8080:8080
nats_portint42224222
leaf_remotes[]string(none)(none)
leaf_credentialsstring(none)(none)
monitor_portint(none)(none)
max_store_bytesint6410737418240 (10 GiB)10737418240 (10 GiB)

On Linux, data_dir respects XDG_DATA_HOME if set.

Environment Variables

Core

VariableOverridesNotes
DAGNATS_DATA_DIRdata_dir
DAGNATS_HTTP_ADDRhttp_addr
DAGNATS_NATS_PORTnats_portMust be a valid integer
DAGNATS_LEAF_REMOTESleaf_remotesComma-separated, max 10 entries
DAGNATS_LEAF_CREDENTIALSleaf_credentialsPath to NATS credentials file
DAGNATS_MONITOR_PORTmonitor_portNATS monitoring HTTP port
DAGNATS_MAX_STORE_BYTESmax_store_bytesMust be a positive integer

Triggers

VariableDefaultNotes
DAGNATS_WEBHOOK_SECRET(none)Default HMAC secret for webhook triggers

When DAGNATS_WEBHOOK_SECRET is set and no --secret flag is provided to dagnats trigger create, the env var value is used. The --secret flag always takes precedence. This keeps secrets out of shell history.

Observability

VariableDefaultNotes
OTEL_EXPORTER_OTLP_ENDPOINT(none)OTLP/HTTP base URL for telemetry

When OTEL_EXPORTER_OTLP_ENDPOINT is set, DagNats subscribes to the internal TELEMETRY span stream and batches spans to {endpoint}/v1/traces via OTLP/HTTP JSON. Works with any OTLP/HTTP-compatible backend (SigNoz, Grafana Tempo, Jaeger). When unset, spans are still written to the NATS TELEMETRY stream but not exported externally. Export failures never affect workflow execution.

OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 dagnats serve

Workers (Config-Driven)

Worker handlers can be defined in the config file and overridden per-task via environment variables:

Variable PatternNotes
DAGNATS_WORKER_{TASK}_EXECShell command to execute
DAGNATS_WORKER_{TASK}_HTTPHTTP endpoint URL
DAGNATS_WORKER_{TASK}_HTTP_METHODHTTP method (default: POST)

Task names are uppercased with hyphens replaced by underscores. For example, a task named call-claude uses DAGNATS_WORKER_CALL_CLAUDE_EXEC.

Deprecated Variables

The following environment variables still work but produce a warning on stderr. Migrate to the new names.

Old NameNew Name
NATS_URLDAGNATS_NATS_URL
LISTEN_ADDRDAGNATS_LISTEN_ADDR

Config File

Place a dagnats.yaml file in the working directory. Format is simple key: value pairs, one per line. Lines starting with # are comments. Maximum 300 lines.

# dagnats.yaml
data_dir: /var/lib/dagnats
http_addr: :9090
nats_port: 4333
leaf_remotes: nats://hub1:7422, nats://hub2:7422
max_store_bytes: 5368709120

# Config-driven workers
worker.summarize.exec: python3 /opt/workers/summarize.py
worker.call-api.http: http://localhost:3000/tasks
worker.call-api.http_method: POST

Unknown keys produce a warning but do not cause an error.

Worker Config in YAML

Each worker needs a task name and either an exec command or an http endpoint (not both):

worker.my-task.exec: /usr/local/bin/my-handler
worker.my-task.http: http://localhost:3000/handle
worker.my-task.http_method: PUT

Maximum of 50 worker configs. Duplicate task names are rejected. Having both exec and http for the same task is rejected.

Inline Leaf Credentials

DAGNATS_LEAF_CREDENTIALS accepts either a file path or inline PEM content. If the value starts with -----BEGIN, DagNats writes it to a secure temp file automatically. This is useful in CI/CD where mounting a credentials file is inconvenient:

DAGNATS_LEAF_CREDENTIALS="-----BEGIN NATS USER JWT-----
eyJ0eXAiOiJK...
------END NATS USER JWT------
-----BEGIN USER NKEY SEED-----
SUAM...
------END USER NKEY SEED------" dagnats serve

Viewing Effective Config

dagnats config show
dagnats config show --json

The config show command loads the resolved configuration (all three tiers merged) and prints it. Use --json for machine-readable output. This is the fastest way to verify which values are active.

Example output:

data_dir:        /Users/you/Library/Application Support/dagnats
http_addr:       :8080
nats_port:       4222
leaf_remotes:    (none)
leaf_credentials:(none)
monitor_port:    (none)
max_store_bytes: 10737418240
otlp_endpoint:   (none)