Search code examples
node.jsforeverforever-monitor

Runnig two instances of a script in forever.js


Is there a way to run two or more instances of the same node script in forever.js? If not what is the best tool used for that?


Solution

  • The best tool (at the moment) to run same node process forever is pm2.

    npm i pm2 -g

    pm2 start app.js -i 2

    This will run two instances of he same app even if your app opens the same port. pm2 uses clustering to route network connections to both instances of the app. You don't even need to bother about clustering, just open any ports and it will work.