Node.js Process Managers

Thanassis Zografos

DevStaff.gr

What is a  Process Managers

A tool or a set of tools that helps during the development period to automate restarting of your app, while on production makes sure that your app is always up 

Process Managers etc

nodemon

pm2

strongloop

supervizer

forever

...

nodemon

For use during development of a node.js based application.

 

nodemon will watch the files in the directory in which nodemon was started, and if any files change, nodemon will automatically restart your node application.

 

nodemon

nodemon does not require any changes to your code or method of development. nodemon simply wraps your node application and keeps an eye on any files that have changed. Remember that nodemon is a replacement wrapper for node, think of it as replacing the word "node" on the command line when you run your script.

nodemon

installation

 

npm install -g nodemon

nodemon

usage

 

nodemon [your node app]
nodemon ./server.js localhost 8080

 

If you have a package.json file for your app, you can omit the main script entirely and nodemon will read the package.json for the main property and use that value as the app.

pm2

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

pm2

installation

 

npm install pm2 -g

pm2

usage

 

pm2 start <app_name>

pm2 stop <app_name|id|'all'|json_conf>

pm2 restart <app_name|id|'all'|json_conf>

pm2 delete <app_name|id|'all'|json_conf>

pm2

Process management

pm2 list

pm2

Process management

pm2 monit

pm2

Process management

pm2 logs

pm2

Load balancing / 0s reload downtime

$ pm2 start app.js -i 0  
# Enable load-balancer and cluster features

$ pm2 reload all           
# Reload all apps in 0s manner

$ pm2 scale <app_name> <instance_number> 
# Increase / Decrease process number

thank you for listening

Thanassis Zografos

lookmeup @

https://www.linkedin.com/in/sonaht

tzografos@ultraweb4u.com

Node.js process managers

By Thanassis Zografos

Node.js process managers

Node.js process managers, pm2 and nodemon

  • 2,372