OC-201c · Module 1

Process Management

3 min read

The most common OpenClaw production failure is not a bug. It is a crash without restart. The Node.js process hits an unhandled exception, exits, and nobody notices until a scheduled task fails to fire hours later. Process management solves this by wrapping OpenClaw in a supervisor that watches the process and restarts it immediately on exit. PM2 is the standard tool for Node.js process management — it handles restarts, log rotation, and process monitoring in a single package.

Beyond crash recovery, process management handles startup sequencing. OpenClaw may depend on services that take time to initialize — a database, a network connection, an API health check. A production process manager lets you define startup dependencies: "wait for the database to be reachable before starting OpenClaw." Without dependency ordering, OpenClaw starts, tries to connect to a database that is not ready yet, and crashes. The process manager restarts it, it crashes again, and you get a restart loop that fills your logs with identical error messages.

# Install PM2 globally
npm install -g pm2

# Start OpenClaw with PM2
pm2 start openclaw --name "openclaw-agent" --max-restarts 10

# Enable startup script (auto-launch on reboot)
pm2 startup
pm2 save

# View logs
pm2 logs openclaw-agent

# Monitor in real-time
pm2 monit