O'Reilly logo

Mastering Node.js - Second Edition by Kevin Faaborg, Sandro Pasquali

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using PM2 to manage multiple processes

PM2 is designed to be an enterprise-level process manager. As discussed elsewhere, Node runs within a Unix process, and its child process and cluster modules are used to spawn further processes, typically when scaling an application across multiple cores. PM2 can be used to instrument deployment and monitoring of your Node processes, both via the command line and programmatically. PM2 spares the developer the complexity of configuring clustering boilerplate, handles restarts automatically, and provides advanced logging and monitoring tools out of the box.

Install PM2 globally: npm install pm2 -g

The most straightforward way to use PM2 is as a simple process runner. The following program will increment ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required