[Whole Web, Node.js, PM2] Restarting your node.js app on code change using pm2

Aadd watch to the config.json file:

{
  "apps": [{
    "name": "App1",
    "script": "app1/server.js",
    "log_file": "log/app1.log",
    "error_file": "log/app1-err.log",
    "watch": true,
    "ignore_watch": ["file"]  //inside app1 folder
  },{
    "name": "App2",
    "script": "app2/server.js",
    "log_file": "log/app2.log",
    "error_file": "log/app2-err.log"
  }]
}

After change app1/server.js, run

pm2 list

You can see App1's pid is changed, but App2 is not. Because we enable the watch on App1 not on App2.

posted @ 2015-04-29 17:12  Zhentiw  阅读(193)  评论(0编辑  收藏  举报