Overview
Theorcbot daemon command manages the OrcBot background daemon process. It provides status checks and graceful shutdown capabilities for daemon instances started with orcbot run --daemon.
Usage
Subcommands
status
Check if the OrcBot daemon is running and display its status.stop
Gracefully stop the running daemon by sending SIGTERM.start
Start the daemon (equivalent toorcbot run --daemon).
- Calls
daemonManager.daemonize()to detach the process - Redirects logs to
~/.orcbot/daemon.log - Writes PID to
~/.orcbot/orcbot.pid - Starts the agent loop
restart
Stop the current daemon (if running) and start a new one.- If daemon is running, sends SIGTERM to current PID
- Waits for graceful shutdown
- Starts new daemon process
- Outputs new PID and log location
Daemon Process Details
PID File
Location:~/.orcbot/orcbot.pid
Contents: Plain text integer (process ID)
Log File
Location:~/.orcbot/daemon.log
Format: Append-only log with timestamps
Lock File
Location:~/.orcbot/orcbot.lock
Contents: JSON with instance metadata
Examples
Start and Monitor Daemon
Graceful Restart
Force Stop Stuck Daemon
Clean Up After Crash
Process Lifecycle
Starting
- Check for existing daemon (via PID file)
- Create
~/.orcbot/orcbot.lockwith instance metadata - Fork process and detach from terminal
- Redirect stdio to
~/.orcbot/daemon.log - Write PID to
~/.orcbot/orcbot.pid - Start agent loop
Running
- Agent executes autonomous reasoning loop
- Processes queued tasks from ActionQueue
- Handles channel events (Telegram, WhatsApp, etc.)
- Runs heartbeat tasks on schedule
- Logs all activity to daemon.log
Stopping
- SIGTERM signal sent to daemon process
- Graceful shutdown initiated:
- Current action completes
- Memory flushed to disk
- Channels disconnected
- Gateway stopped (if running)
- PID file removed
- Lock file removed
- Process exits
Integration with Other Commands
orcbot run
orcbot stop
orcbot status
Troubleshooting
Daemon Logs Growing Large: Daemon logs are append-only and can grow over time:
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Daemon not running (for stop command) |
| 1 | Failed to send stop signal |
Related Commands
orcbot run- Start agent with daemon optionorcbot stop- Stop all OrcBot processesorcbot status- View overall agent statusorcbot ui- Interactive TUI for management