Tasks Configuration
enableWorker: Whether to enable Worker (default:trueonly whenNODE_TYPE=daemon)workerOptions.concurrency: Number of concurrent tasks (default: CPU core count - 1)workerOptions.usePubSub: Use PostgreSQL LISTEN/NOTIFY (default: true)workerOptions.listenDelay: Wait time after receiving Pub/Sub message (default: 500ms)contextProvider: Function to create Context used within Workflows
WorkflowManager
Sonamu automatically creates and manages theWorkflowManager. Access it via Sonamu.workflows.
Worker Modes
1. Daemon Mode (Auto-enabled)
There is no separate daemon command. Whentasks.enableWorker is not set, Sonamu enables the Worker
only for processes started with NODE_TYPE=daemon. The Worker is created during Sonamu.init() and
started after the server begins listening.
enableWorker explicitly to override this detection on any node.
2. Separate Worker Process
startWorker() starts only the Worker that Sonamu.init() created. Set tasks.enableWorker: true
or run this process with NODE_TYPE=daemon; otherwise it initializes the task backend without a
Worker.
3. API Server + Worker
Distributed Workers
You can run Workers on multiple servers.Context Provider
Customize the Context used in Workflows.systemUserId in ContextExtend so they are typed.
Access via Sonamu.getContext() within a Workflow function:
Table Structure
The task backend runs its own migrations and creates thesonamu_tasks schema in the main database
with two tables:
Monitoring
Check Running Workflows
Logging
Next Steps
@workflow Decorator
Define Workflows
Step
Divide tasks with Steps