Search code examples
node.jsexpresspm2express-4

Express 4 + pm2 watch not working


I'm running pm2 with this:

pm2 start bin/www --watch ../

Problem is that when I update app.js in the root folder, it doesn't seem to be autorestarting node. Any ideas?


Solution

  • Figured out a solution:

    //processes.json:
        {
          "apps" : [{
            "name"        : "someExpress4App",
            "script"      : "bin/www",
            "watch"       : "../",
            "log_date_format"  : "YYYY-MM-DD HH:mm Z",
          }]
        }
    

    Put that on the root of your project, then run your pm2 as so:

    pm2 start processes.json