PM2

315 阅读1分钟

启动

$ pm2 start [app.js|script.sh]

-i [num] // 启动num个实例,自动负载均衡 --name // 启动名称 --watch // 当文本变化会重新启动

$ pm2 scale [app-name] [num] // 扩展实例

$ pm2 reset [app-name] // 重置重启数量

查看

$ pm2 ls // 查看启用程序

$ pm2 // 显示cpu和内存情况

$ pm2 show [app-name] // 显示信息

$ pm2 logs ?[app-name] // 查看日志

关闭

$ pm2 stop [all | [id]] // 停用

$ pm2 restart all // 重启所有应用

$ pm2 reload all // 重启cluster mode下的所有应用

$ pm2 delete [all | [id]]

开机自启动

$ pm2 startup [ubuntu | ubuntu14 | ubuntu12 | centos | centos6 | arch | oracle | amazon | macos | darwin | freebsd | systemd | systemv | upstart | launchd | rcd | openrc] // 创建开机自启动命令(可以指定os)

$ pm2 save // 保存当前应用列表

$ pm2 resurrect // 重新加载保存的应用列表

官网链接