pm2 start xxx.js
pm2 del xxx.js/id
pm2 stop xxx.js/id
pm2 save //保存任务列表 ~/.pm2目录
pm2 startup
pm2 resurrect //恢复
多线程模式
pm2 start app.js -i max
- 0/max将应用程序分布在所有 CPU 上
- -1将应用程序分布到所有 CPU - 1
- number将应用程序分布在number 个CPU上
配置文件启动
processes.json
module.exports = {
apps : [{
script : "api.js",
instances : "max",
exec_mode : "cluster"
}]
}
然后 pm2 start processes.json
pm2 restart all //重启线程
实时扩展集群
pm2 scale <app name> <n>
pm2 scale app +3