forever 替代工具 pm2 的介绍

[Goodbye node-forever, hello PM2][pm2] [pm2]: (http://devo.ps/blog/2013/06/26/goodbye-node-forever-hello-pm2.html)

看了工具的介绍, 觉得蛮方便的, 就是不支持 CoffeeScript 让人有点抓狂:

Github: https://github.com/Unitech/pm2

npm install -g pm2

特点

PM2 觉得 Forever 有一些不好用的地方:

  • log 和监视的功能有限
  • 进程和集群管理有限
  • Aging codebase (升级 Node 容易导致应用失败)

目测比 Forever 好用一些… PM2 是前几个月刚写的, 还不完善: 列出来的计划有:

  • Remote administration/status checking,
  • Built-in inter-processes communication channel (message bus),
  • V8 GC 内存泄露检测,
  • Web 界面,
  • Persistent storage for monitoring data,
  • 邮件通知

Demo

盗链个截图:

然后本地安装尝试了一下:

➤➤ cat a.js 
// Generated by CoffeeScript 1.6.3require('http').createServer(function(req, res){return res.end('ok');}).listen(3000);➤➤ pm2 start a.js 
 PM2 Configuration:{ script:'a.js', name:'a'} PM2 You can write the current configuration by adding -w option
 PM2 Process launched
┌────────┬────┬───────┬────────┬───────────┬─────────────────────┬──────────┬────────────────────────────────┐Script id  PID    status RestartedLast restart           memory  err logs                       ├────────┼────┼───────┼────────┼───────────┼─────────────────────┼──────────┼────────────────────────────────┤ a.js   027515 online 02013-06-2714:16:288.469 MB /home/yong/.pm2/logs/a-err.log ➤➤ pm2 list
 PM2  Process listing
┌────────┬────┬───────┬────────┬───────────┬─────────────────────┬───────────┬────────────────────────────────┐Script id  PID    status RestartedLast restart            memory  err logs                       ├────────┼────┼───────┼────────┼───────────┼─────────────────────┼───────────┼────────────────────────────────┤ a.js   027515 online 02013-06-2714:16:2810.102 MB /home/yong/.pm2/logs/a-err.log └────────┴────┴───────┴────────┴───────────┴─────────────────────┴───────────┴────────────────────────────────┘ PM2  PM2 log file path :/home/yong/.pm2/pm2.log  (type pm2 logs to see log streaming) PM2 monitoring :

a.js [27515][]0%[|||]10.102 MB

➤➤ pm2 kill
Daemon killed

➤➤ pm2 logs
Launching daemon
{ online:true, success:true, pid:27553}[PM2 DAEMON (l0)]"/opt/s/demo/a.coffee -省略省略...

猜你喜欢

转载自stuming-zeng.iteye.com/blog/2381937
今日推荐