Manage app with process manager

suggest change

Run a Node.js app under a process manager so it restarts after a crash and can reload without downtime. PM2 also handles logs, monitoring, and a built-in load balancer.

PM2 process manager

Installing PM2:

npm install pm2 -g

Process can be started in cluster mode involving integrated load balancer to spread load between processes:

pm2 start app.js -i 0 --name "api" (-i is to specify number of processes to spawn. If it is 0, then process number will be based on CPU cores count)

If several users run PM2, set one shared home. Otherwise each user gets a separate daemon and a config under that user's home directory.

Usage: PM2_HOME=/etc/.pm2 pm2 start app.js

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents