What the Daemon Does
When the daemon is running, it handles four main responsibilities:- Manages agent connections — Keeps your AI agents online and ready to respond to messages across all connected channels.
- Processes messages — Routes incoming messages to the right agent, sends them to your AI provider, and delivers the response back to the user.
- Runs scheduled tasks — Executes cron jobs, heartbeat health checks, and any tasks your agents have scheduled for themselves.
- Monitors system health — Watches disk space, CPU, memory, and other vital signs, alerting you if something needs attention.
Starting Up
When you start the daemon, it goes through a careful initialization sequence: loading your configuration, connecting to channels, starting agents, and beginning health monitoring. The whole process typically takes one to three seconds. When it finishes, you will see a startup banner in the logs:What Happens During Startup
Behind the scenes, the daemon runs through these steps in order:- Loads environment variables from
~/.comis/.env - Decrypts any stored secrets (API keys, tokens)
- Hardens file permissions on the data directory (
~/.comis/) - Reads configuration from the paths in
COMIS_CONFIG_PATHS(default:~/.comis/config.yaml) — for the full config-path syntax, see Configuration - Sets up logging (file transport, per-module log levels)
- Initializes observability (token tracking, latency recording)
- Opens the memory database (SQLite with full-text search)
- Creates agent executors with their configured models
- Starts channel adapters (Telegram, Discord, Slack, etc.)
- Starts the scheduler (cron jobs, heartbeat monitoring)
- Launches the gateway server (HTTP, WebSocket, web dashboard)
- Registers graceful shutdown handlers
Running
Once started, the daemon runs continuously in the background. It processes messages as they arrive, runs health checks at regular intervals (every 5 minutes by default), and collects system metrics every 30 seconds. You do not need to interact with the daemon while it is running — it handles everything automatically. To check on it, view the logs or visit the Web Dashboard.Shutting Down
When you stop the daemon (by sending a stop signal like SIGTERM), it performs a graceful shutdown. This means it does not just cut everything off — it carefully stops each component in the right order to avoid losing data or leaving connections open. Here is what the shutdown sequence looks like in the logs:- Session summary — Logs total executions, cost, and token usage for the session.
- Graph coordinator — Stops any running multi-agent pipelines.
- Sub-agent runner — Drains active sub-agent tasks.
- Cron schedulers — Stops scheduled jobs.
- Channel adapters — Disconnects from messaging platforms (no new messages accepted).
- Heartbeat runner — Stops health checks.
- Gateway server — Closes HTTP and WebSocket connections.
- Observability — Removes event subscriptions.
- Memory database — Closes the SQLite database cleanly.
The daemon waits up to 30 seconds for everything to stop cleanly. Active
conversations will finish processing before shutdown completes. If a component
takes too long, the daemon logs a timeout warning and forces an exit.
Recovering from Problems
Last-Known-Good Config
Every time the daemon starts successfully, it saves a copy of the working configuration file as a “last-known-good” snapshot. If you make a config change that prevents the daemon from starting, you can use this snapshot to recover. When a startup failure occurs due to a bad config change, you will see output like this:Common Startup Errors
If the daemon fails to start, the error message tells you what went wrong:| Error Message | Meaning | What to Do |
|---|---|---|
Bootstrap failed: Config file not found | The configuration file is missing | Check that ~/.comis/config.yaml exists |
Secrets bootstrap failed | Invalid or missing master encryption key | Check SECRETS_MASTER_KEY in your .env file |
Secret decryption failed | The secrets database is corrupted | Delete ~/.comis/secrets.db and re-enter your secrets |
SecretRef resolution failed | A config value references a missing secret | Check SecretRef entries in your config |
Configuration
The daemon has several configuration options that control its behavior. Most users do not need to change these — the defaults work well for typical installations.| Setting | Default | What It Controls |
|---|---|---|
shutdownTimeoutMs | 30000 (30s) | Maximum time to wait for graceful shutdown before forcing exit. |
metricsIntervalMs | 30000 (30s) | How often CPU, memory, and event loop metrics are collected. |
Logging
Understanding log output and controlling log levels.
Monitoring
What the daemon monitors and how alerts work.
systemd
Running the daemon as a Linux system service.
pm2
Managing the daemon with pm2 process manager.
Docker
Running the daemon in a Docker container.
Troubleshooting
Solving common startup and runtime problems.
