Skip to main content

Overview

The orcbot 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.
Output when running:
Output when stopped:
Stale PID handling: If a PID file exists but the process is not running, the status command automatically cleans up the stale file:

stop

Gracefully stop the running daemon by sending SIGTERM.
Output:
If daemon is not running:

start

Start the daemon (equivalent to orcbot run --daemon).
This is an alias that:
  1. Calls daemonManager.daemonize() to detach the process
  2. Redirects logs to ~/.orcbot/daemon.log
  3. Writes PID to ~/.orcbot/orcbot.pid
  4. Starts the agent loop

restart

Stop the current daemon (if running) and start a new one.
Behavior:
  1. If daemon is running, sends SIGTERM to current PID
  2. Waits for graceful shutdown
  3. Starts new daemon process
  4. 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
Viewing logs in real-time:

Lock File

Location: ~/.orcbot/orcbot.lock Contents: JSON with instance metadata
This lock file prevents multiple instances from running simultaneously.

Examples

Start and Monitor Daemon

Graceful Restart

Force Stop Stuck Daemon

Clean Up After Crash

Process Lifecycle

Starting

  1. Check for existing daemon (via PID file)
  2. Create ~/.orcbot/orcbot.lock with instance metadata
  3. Fork process and detach from terminal
  4. Redirect stdio to ~/.orcbot/daemon.log
  5. Write PID to ~/.orcbot/orcbot.pid
  6. Start agent loop

Running

  1. Agent executes autonomous reasoning loop
  2. Processes queued tasks from ActionQueue
  3. Handles channel events (Telegram, WhatsApp, etc.)
  4. Runs heartbeat tasks on schedule
  5. Logs all activity to daemon.log

Stopping

  1. SIGTERM signal sent to daemon process
  2. Graceful shutdown initiated:
    • Current action completes
    • Memory flushed to disk
    • Channels disconnected
    • Gateway stopped (if running)
  3. PID file removed
  4. Lock file removed
  5. Process exits

Integration with Other Commands

orcbot run

orcbot stop

orcbot status

Troubleshooting

Daemon Won’t Start: If orcbot run --daemon fails with “already running” error:
Daemon Won’t Stop: If orcbot daemon stop doesn’t stop the process:
Daemon Logs Growing Large: Daemon logs are append-only and can grow over time:

Exit Codes

  • orcbot run - Start agent with daemon option
  • orcbot stop - Stop all OrcBot processes
  • orcbot status - View overall agent status
  • orcbot ui - Interactive TUI for management