Node Process Managers

From Logic Wiki
Jump to: navigation, search


For production, you should not simply use node app.j — if your app crashes, it will be offline until you restart it.

When you run Express apps for production, it is helpful to use a process manager to:

  • Restart the app automatically if it crashes.
  • Gain insights into runtime performance and resource consumption.
  • Modify settings dynamically to improve performance.
  • Control clustering.

The most popular process managers for Node are:

Check here for comparison

Using PM2

For pm2 you can use cluster directly through a command. For example,

# Start 4 worker processes
pm2 start app.js -i 4
# Auto-detect number of available CPUs and start that many worker processes
pm2 start app.js -i max