← Back to list

pm2-process
by octave-commons
A myth engine
⭐ 1🍴 0📅 Jan 25, 2026
SKILL.md
name: pm2-process description: PM2 process management for Node.js applications in production license: MIT compatibility: opencode metadata: audience: devops runtime: node
What I do
- Configure PM2 for Node.js application management
- Set up process files and clustering
- Monitor logs, metrics, and process health
- Configure auto-restart strategies and graceful shutdown
- Deploy applications with zero-downtime
- Troubleshoot process crashes and performance issues
When to use me
Use me when managing Node.js applications in production, especially when:
- Running Node.js services on servers
- Need process clustering and auto-restart
- Monitoring application health and logs
- Deploying with minimal downtime
- Managing environment-specific configurations
Common commands
pm2 start app.js- Start applicationpm2 start ecosystem.config.js- Start with config filepm2 list- List all processespm2 logs- View logspm2 monit- Real-time monitoringpm2 reload all- Zero-downtime reloadpm2 restart app- Restart processpm2 stop all- Stop all processespm2 delete all- Remove all processes
Ecosystem configuration
module.exports = {
apps: [{
name: 'my-app',
script: './dist/index.js',
instances: 'max',
exec_mode: 'cluster',
env: {
NODE_ENV: 'development',
PORT: 3000
},
env_production: {
NODE_ENV: 'production',
PORT: 8080
},
error_file: './logs/error.log',
out_file: './logs/out.log',
log_date_format: 'YYYY-MM-DD HH:mm:ss Z',
merge_logs: true,
autorestart: true,
max_memory_restart: '1G',
watch: false
}]
};
Clustering strategies
- Use
instances: 'max'for CPU cores - Use
instances: 4for fixed cluster size - Enable
exec_mode: 'cluster'for multi-instance - Sticky sessions:
exec_mode: clusterwith load balancer
Log management
- Configure separate error and output logs
- Rotate logs with
pm2 install pm2-logrotate - Set log file size limits and retention
- Use
pm2 flushto clear logs - Stream logs to external services (e.g., ELK, Datadog)
Monitoring
- Use
pm2 monitfor real-time metrics - Install
pm2-plusfor advanced monitoring - Set up custom metrics with
pmx - Monitor CPU, memory, and event loop lag
- Set up alerts for process crashes
Graceful shutdown
- Handle SIGTERM signals in application code
- Close database connections before exit
- Drain HTTP connections gracefully
- Use
pm2 reloadinstead ofrestartfor zero downtime - Configure
kill_timeoutandwait_ready
Environment management
- Separate configs per environment (
env_production,env_staging) - Load env vars from
.envfiles - Use
pm2 startupto generate startup script - Save process list with
pm2 save
Deployment patterns
- Build before starting (
npm run build && pm2 start) - Use
pm2 deploywith git-based deployment - Implement health checks before accepting traffic
- Rollback with
pm2 reload app --update-env
Score
Total Score
50/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
Reviews
💬
Reviews coming soon