Process manager is generally used in production to deploy a nodejs app. The main functions of a process manager are restarting the server if it crashes, checking resource consumption, improving runtime performance, monitoring etc.
Some of the popular process managers made by the node community are forever, pm2, etc. forever is a command-line interface tool for ensuring that a given script runs continuously. forever ’s simple interface makes it ideal for running smaller deployments of Node.js apps and scripts. forever monitors your process and restarts it if it crashes.
- $ npm install -g forever
- $ forever start server.js
This starts the server and gives an id for the process(starts from 0).
- $ forever restart 0
Here 0 is the id of the server.
- $ forever stop 0
Similar to restart, 0 is the id the server.