Node.js Process Manager (pm2)
Installation
npm install pm2@latest -g
yarn global add pm2
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:
pm2 start app.js
Or start any other application easily
pm2 start bashscript.sh
pm2 start python-app.py --watch
pm2 start binary-file -- --port 1520
Managing processes
Managing application state is simple here are the commands:
restart
pm2 restart app_name
reload
pm2 reload app_name
stop
pm2 stop app_name
delete
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:
pm2 [list|ls|status]
Terminal Based Dashboard
Here is a realtime dashboard that fits directly into your terminal:
pm2 monit