Skip to content

Node.js Process Manager (pm2)

Installation

Terminal window
npm install pm2@latest -g

To install Node.js and NPM you can use NVM

Start an app

The simplest way to start, daemonize and monitor your application is by using this command line:

Terminal window
pm2 start app.js

Or start any other application easily

Terminal window
pm2 start bashscript.sh
Terminal window
pm2 start python-app.py --watch
Terminal window
pm2 start binary-file -- --port 1520

Managing processes

Managing application state is simple here are the commands:

restart

Terminal window
pm2 restart app_name

reload

Terminal window
pm2 reload app_name

stop

Terminal window
pm2 stop app_name

delete

Terminal window
pm2 delete app_name

Instead of app_name you can pass:

  • all to act on all processes
  • id to act on a specific process id

Check status, logs, metrics

Now that you have started this application, you can check its status, logs, metrics and even get the online dashboard with pm2.io.

List managed applications

List the status of all application managed by PM2:

Terminal window
pm2 [list|ls|status]

Terminal Based Dashboard

Here is a realtime dashboard that fits directly into your terminal:

Terminal window
pm2 monit