Environment Variables
Configure TaskDaemon via environment variables.
Available Variables
| Variable | Default | Description |
|---|
HANDLER_CONFIG | handlers.toml | Path to handler configuration file |
DAEMON_PORT | 8080 | HTTP server port |
DAEMON_GRPC_PORT | 50051 | gRPC server port |
DAEMON_WORKERS | 2 | Number of worker threads |
DAEMON_DB_PATH | /tmp/task_queue.db | SQLite database path |
DAEMON_DB_MAX_CONNECTIONS | 20 | SQLite connection pool size |
DAEMON_QUEUE_TYPE | sqlite | Queue type: sqlite or hybrid |
DAEMON_TASK_SELECTION | fifo | Task selection: fifo, lifo, priority |
DAEMON_LOG_LEVEL | info | Log level (trace, debug, info, warn, error) |
DAEMON_HOST | 0.0.0.0 | HTTP server bind address |
DAEMON_MAX_RETRIES | 3 | Maximum retry attempts for failed tasks |
DAEMON_TASK_TIMEOUT | 30 | Default task timeout in seconds |
Queue Types
Standard SQLite-backed queue. Durable but slightly slower under high load. In-memory queue with SQLite persistence. Faster dequeue with durability.Recommended for high-throughput workloads. Tasks are kept in memory for fast access but persisted to SQLite for crash recovery.
Task Selection
| Value | Description |
|---|
fifo | First-In-First-Out (default) |
lifo | Last-In-First-Out |
priority | Highest 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 Flag | Environment Variable |
|---|
--workers | DAEMON_WORKERS |
--http-port | DAEMON_PORT |
--grpc-port | DAEMON_GRPC_PORT |
--db-path | DAEMON_DB_PATH |
--log-level | DAEMON_LOG_LEVEL |
--task-selection | DAEMON_TASK_SELECTION |
--config | HANDLER_CONFIG |
Precedence
Configuration is applied in this order (later overrides earlier):
- Default values
- Environment variables
- CLI arguments
# DAEMON_WORKERS=4 in environment
# --workers 8 on command line
# Result: 8 workers (CLI wins)
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
| Level | Description |
|---|
trace | Very detailed debugging |
debug | Debugging information |
info | General operational info |
warn | Warning messages |
error | Error messages only |