Skip to main content

Environment Variables

Configure TaskDaemon via environment variables.

Available Variables

VariableDefaultDescription
HANDLER_CONFIGhandlers.tomlPath to handler configuration file
DAEMON_PORT8080HTTP server port
DAEMON_GRPC_PORT50051gRPC server port
DAEMON_WORKERS2Number of worker threads
DAEMON_DB_PATH/tmp/task_queue.dbSQLite database path
DAEMON_DB_MAX_CONNECTIONS20SQLite connection pool size
DAEMON_QUEUE_TYPEsqliteQueue type: sqlite or hybrid
DAEMON_TASK_SELECTIONfifoTask selection: fifo, lifo, priority
DAEMON_LOG_LEVELinfoLog level (trace, debug, info, warn, error)
DAEMON_HOST0.0.0.0HTTP server bind address
DAEMON_MAX_RETRIES3Maximum retry attempts for failed tasks
DAEMON_TASK_TIMEOUT30Default task timeout in seconds

Queue Types

Standard SQLite-backed queue. Durable but slightly slower under high load.
DAEMON_QUEUE_TYPE=sqlite

Task Selection

ValueDescription
fifoFirst-In-First-Out (default)
lifoLast-In-First-Out
priorityHighest priority first
See Task Selection Strategies for details.

Usage

Docker

docker run -d \
  -e DAEMON_WORKERS=100 \
  -e DAEMON_QUEUE_TYPE=hybrid \
  -e DAEMON_TASK_SELECTION=priority \
  -e DAEMON_DB_MAX_CONNECTIONS=50 \
  -e DAEMON_LOG_LEVEL=info \
  -v ./handlers.toml:/app/handlers.toml \
  -v /var/run/docker.sock:/var/run/docker.sock \
  mshelia/taskdaemon

Docker Compose

services:
  taskdaemon:
    image: mshelia/taskdaemon:latest
    environment:
      - DAEMON_WORKERS=100
      - DAEMON_QUEUE_TYPE=hybrid
      - DAEMON_TASK_SELECTION=priority
      - DAEMON_DB_MAX_CONNECTIONS=50
      - DAEMON_LOG_LEVEL=info
    volumes:
      - ./handlers.toml:/app/handlers.toml
      - /var/run/docker.sock:/var/run/docker.sock
      - task-data:/data

volumes:
  task-data:

Shell

export DAEMON_WORKERS=100
export DAEMON_QUEUE_TYPE=hybrid
export DAEMON_TASK_SELECTION=fifo
./target/release/task-daemon --config handlers.toml

CLI Arguments

CLI arguments override environment variables:
CLI FlagEnvironment Variable
--workersDAEMON_WORKERS
--http-portDAEMON_PORT
--grpc-portDAEMON_GRPC_PORT
--db-pathDAEMON_DB_PATH
--log-levelDAEMON_LOG_LEVEL
--task-selectionDAEMON_TASK_SELECTION
--configHANDLER_CONFIG

Precedence

Configuration is applied in this order (later overrides earlier):
  1. Default values
  2. Environment variables
  3. CLI arguments
# DAEMON_WORKERS=4 in environment
# --workers 8 on command line
# Result: 8 workers (CLI wins)

Performance Tuning

For high-throughput workloads:
DAEMON_WORKERS=100              # Match to handler instances
DAEMON_QUEUE_TYPE=hybrid        # Faster dequeue
DAEMON_DB_MAX_CONNECTIONS=50    # More DB connections
DAEMON_TASK_SELECTION=fifo      # Predictable ordering
Set DAEMON_WORKERS to roughly match the total number of handler instances across all handlers for optimal utilization.

Log Levels

LevelDescription
traceVery detailed debugging
debugDebugging information
infoGeneral operational info
warnWarning messages
errorError messages only