Show Menu
Cheatography

PM2 - Process Manager for Node.js Cheat Sheet by

Advanced, production process manager for Node.js

What is PM2?

PM2 is a production process manager for Node.js applic­ations with a built-in load balancer. It allows you to keep applic­ations alive forever, to reload them without downtime and to facilitate common system admin tasks.

Instal­lation:
npm install pm2 -g

Listing

pm2 list
Display all processes status
pm2 jlist
Print process list in raw JSON
pm2 prettylist
Print process list in beautified JSON
pm2 describe 0
Display all inform­ations about a specific process (id 0)
pm2 monit
Monitor all processes

Logs

pm2 logs [--raw]
Display all processes logs in streaming
pm2 flush
Empty all log file
pm2 reloadLogs
Reload all logs

Actions

pm2 stop all
Stop all processes
pm2 restart all
Restart all processes
pm2 reload all
Will 0s downtime reload (for NETWORKED apps)
pm2 gracef­ulR­eload all
Send exit message then reload (for networked apps)
pm2 stop 0
Stop specific process id (0)
pm2 restart 0
Restart specific process id (0)
pm2 delete 0
Will remove process from pm2 list (id=0)
pm2 delete all
Will remove all processes from pm2 list

Misc.

pm2 reset <pr­oce­ss>
Reset meta data (restarted time...)
pm2 updatePM2
Update in memory pm2
pm2 ping
Ensure pm2 daemon has been launched
pm2 sendSignal SIGUSR2 my-app
Send system signal to script (my-app)
pm2 start app.js --no-d­aemon
pm2 start app.js --no-v­izion
pm2 start app.js --no-a­uto­restart
pm2 start app.js --name my-api # Name process
Fork mode
pm2 start app.js -i 0
Cluster mode - Will start maximum processes with LB depending on available CPUs
pm2 start app.js -i max
Cluster mode - Same as above, but deprecated yet
               
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          JavaScript Cheat Sheet
          SailsJS Cheat Sheet

          More Cheat Sheets by nire0510

          Feditor Keyboard Shortcuts
          Command Line API Reference Cheat Sheet