Documentation Index
Fetch the complete documentation index at: https://mintlify.com/onesoft-sudo/sudobot/llms.txt
Use this file to discover all available pages before exploring further.
PM2 is a production process manager for Node.js applications. SudoBot ships with an ecosystem.config.js configured for PM2, giving you automatic restarts on crashes, structured log files, and easy start/stop/restart control from the command line.
Prerequisites
- SudoBot built (
./blazew build completed)
- Node.js v21+ installed
- PM2 installed globally
Starting SudoBot with PM2
SudoBot’s ecosystem.config.js defines an app named sudobot that runs build/out/main/typescript/main.js with NODE_ENV=production.
# Start using the included config
npm run start:prod
This is equivalent to:
pm2 start ecosystem.config.js --env production
Common PM2 commands
# View running processes
pm2 list
# View real-time logs
pm2 logs sudobot
# Restart the bot
pm2 restart sudobot
# Stop the bot
pm2 stop sudobot
# Delete from PM2 process list
pm2 delete sudobot
Log files
When a logs/ directory exists in the project root, PM2 writes to:
| File | Contents |
|---|
logs/debug.log | Combined stdout/stderr output |
logs/error.log | Error output only |
Create the directory before starting PM2 to enable file logging:
mkdir -p logs
pm2 start ecosystem.config.js --env production
Auto-start on system reboot
To have PM2 (and SudoBot) start automatically when your server reboots:
Generate a startup script
PM2 prints a command to run with sudo. Copy and run that command. Save the current process list
PM2 saves the list of running processes. They will be restored automatically on reboot.
Checking the ecosystem config
The included ecosystem.config.js looks like this:
const config = {
apps: [
{
name: "sudobot",
script: "build/out/main/typescript/main.js",
env_production: {
NODE_ENV: "production"
},
autorestart: true,
log_date_format: "YYYY-MM-DD HH:mm:ss Z",
log_file: "logs/debug.log",
error: "logs/error.log"
}
]
};
You can modify this file to change the process name, add environment variables, or adjust restart behavior.
To run multiple SudoBot instances (e.g. for different Discord applications), duplicate the app entry in ecosystem.config.js with different names and .env file paths, then use PM2’s --env flag to switch between them.