使用PM2将Node.js的集群

  |   IT Linux

当你关闭终端窗口或者从 SSH 断开连接时,Ghost 就停止了。为了防止Ghost停止工作,我们得以解决方法就是用PM2。

让PM2保持Ghost运行

npm install pm2 -g  
NODE_ENV=production pm2 start index.js --name "ghost"  
pm2 startup centos  
pm2 save  

运行

pm2 start app.js

查看运行状态

pm2 list

追踪资源运行情况

pm2 monit

查看所有日志

pm2 logs

重启应用

pm2 restart [app id]

停止应用

pm2 stop [app id]

查看更多命令:
http://www.jianshu.com/p/fdc12d82b661