Prerequisites
Before setting up pm2, make sure you have:- Node.js 22 or newer installed
- Comis built — run
pnpm buildin the Comis directory - pm2 installed globally:
Setup
Generate the config file
Run the setup command to generate the pm2 ecosystem config:Expected output:This creates
~/.comis/ecosystem.config.js with the correct paths to your
daemon binary and configuration file. You do not need to edit this file.Common commands
| Command | What it does |
|---|---|
node packages/cli/dist/cli.js pm2 start | Start the daemon |
node packages/cli/dist/cli.js pm2 stop | Stop the daemon |
node packages/cli/dist/cli.js pm2 restart | Restart the daemon |
pm2 status comis | Check if the daemon is running |
pm2 logs comis | View live logs (streaming) |
pm2 logs comis --lines 50 --nostream | View the last 50 log lines and exit |
After rebuilding Comis (
pnpm build), always restart the daemon to pick up the
new code:Auto-start on boot
By default, pm2 processes stop when the server reboots. To make Comis start automatically on boot: 1. Generate the startup script:sudo. Copy and run the
exact command it shows you. For example:
Ecosystem config
Thepm2 setup command generates a config file at ~/.comis/ecosystem.config.js.
Here is what it contains:
| Field | Value | What it means |
|---|---|---|
name | "comis" | The process name used in all pm2 commands |
script | Path to daemon.js | The Node.js file to run |
COMIS_CONFIG_PATHS | Config file path | Tells the daemon where to find config.yaml |
restart_delay | 2000 | Wait 2 seconds between restart attempts |
kill_timeout | 10000 | Wait 10 seconds for the daemon to shut down gracefully |
max_restarts | 10 | Give up after 10 consecutive crashes (prevents restart loops) |
autorestart | true | Automatically restart if the daemon crashes |
Log management
pm2 stores its logs in~/.pm2/logs/, not in ~/.comis/. You will find two files:
comis-out.log— standard output (normal log messages)comis-error.log— standard error (error messages)
The daemon also supports its own file logging with rotation. See
Logging for details on configuring the daemon’s built-in
log rotation.
Related pages
Daemon
How the daemon starts, runs, and shuts down.
systemd
Run Comis as a systemd service on Linux.
Docker
Run Comis in a Docker container.
Logging
Configure log levels, rotation, and structured output.
Troubleshooting
Solutions to common issues.
