PM2
PM2 vs Supervisor
Section titled “PM2 vs Supervisor”| Feature | PM2 | Supervisor |
|---|---|---|
| Ecosystem | JavaScript | Python |
| Cluster Mode | ✅ | ❌ |
| Zero-downtime | ✅ | ❌ |
| Load Balancing | ✅ Built-in | ❌ |
| Dashboard | ✅ Built-in | ❌ |
Installation
Section titled “Installation”npm install -g pm2pm2 --versionQuick Start
Section titled “Quick Start”# Start apppm2 start server.py --name snapcode --interpreter python3
# View statuspm2 status
# View logspm2 logs snapcodeWith Config File
Section titled “With Config File”ecosystem.config.js
Section titled “ecosystem.config.js”module.exports = { apps: [{ name: 'snapcode', script: 'server.py', interpreter: 'python3', instances: 1, autorestart: true, max_memory_restart: '500M', env: { PORT: 8000 } }]};pm2 start ecosystem.config.jspm2 savepm2 startupManagement
Section titled “Management”pm2 start snapcode # Startpm2 stop snapcode # Stoppm2 restart snapcode # Restartpm2 reload snapcode # Zero-downtime reloadpm2 delete snapcode # Removepm2 logs snapcode # Logspm2 monit # DashboardFeatures
Section titled “Features”- ✅ Cluster mode (multiple instances)
- ✅ Zero-downtime reload
- ✅ Built-in load balancing
- ✅ Built-in monitoring dashboard
- ✅ Auto-restart on crash