-
Notifications
You must be signed in to change notification settings - Fork 9
PM2 Node.js Process Management
Michael Hulse edited this page Feb 28, 2018
·
11 revisions
You can use PM2 to manage Node.js apps:
Advanced, production process manager for Node.js
http://pm2.keymetrics.io/
Note: PM2 is connected to user; on multi-user boxes, PM2 can be run as root; if you login to the server under your own username (e.g., production server), and you want to PM2 manage Node apps on that server, run sudo -i before running any of the pm2 commands below.
# To start a node process using PM2, navigate to the app's server.js (or whatever file is the main server JS file):
$ cd <this repo>/server/server.js
# … and run:
$ pm2 start server.js --name site.com --watch
# To save your list of running apps so they start when server gets restarted:
$ pm2 save
# If --watch is enabled, stopping it won’t stop watching! You must do:
$ pm2 stop site.com --watch 0
# If you have saved your list of PM2 processes in the past, and they are not listed, you can re-initialize them:
$ pm2 resurrect
# To view running apps (should be root user, but may be others):
$ pm2 list
# Remove app from PM2:
$ pm2 delete site.com
# To view app error logs:
$ pm2 log --lines 500