Expressjs pm2 ignore watch public/images folder

Vuong Tran picture Vuong Tran · Jun 28, 2016 · Viewed 15.6k times · Source

I have a website using nodejs. Problem is when user upload images the site stop working. That because of PM2 restart server when file change I think. How to solve this problem. thank you

Answer

Rafal Wiliński picture Rafal Wiliński · Jun 28, 2016

PM2 has special flag --ignore-watch flag.

Try creating file process.json in the same directory where your app.js/index.js is and paste this:

{
  "watch": ["server", "client"],
  "ignore_watch" : ["node_modules", "public/images"],
  "watch_options": {
    "followSymlinks": false
  }
}

More on that topic: http://pm2.keymetrics.io/docs/usage/watch-and-restart/