Skip to main content
pm2 is a process manager that keeps Comis running in the background, restarts it if it crashes, and provides easy log viewing. It works on both Linux and macOS, making it the recommended choice for most users.

Prerequisites

Before setting up pm2, make sure you have:
  • Node.js 22 or newer installed
  • Comis built — run pnpm build in the Comis directory
  • pm2 installed globally:

Setup

1

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.
The generated ecosystem config automatically sets COMIS_CONFIG_PATHS so you do not need to manage environment variables manually. This avoids the common pitfall of environment variables not propagating to background processes.
2

Start Comis

Start the daemon through pm2:
Expected output:
3

Verify it is running

Check the process status:
You should see a table with status: online:
Then check the logs to confirm the daemon started successfully:
Look for "Comis daemon started" in the output.

Common commands

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:
This prints a command that you need to run with sudo. Copy and run the exact command it shows you. For example:
2. Save the current process list:
Now pm2 will restore the Comis process automatically on every reboot.

Ecosystem config

The pm2 setup command generates a config file at ~/.comis/ecosystem.config.js. Here is what it contains:
Here is what each field does:

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)
Clear old logs:
Set up automatic log rotation:
This prevents log files from growing indefinitely. The default rotation keeps logs under 10 MB per file.
The daemon also supports its own file logging with rotation. See Logging for details on configuring the daemon’s built-in log rotation.
Do not use export COMIS_CONFIG_PATHS=... separately from the start command. The ecosystem config handles this for you. Setting it separately may not propagate to the background process, causing a “Config file not found” error.

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.