Node.js Deploying Node.js applications in production Deployment using process manager

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

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.

Forvever

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.

Install forever globally.

$ npm install -g forever

Run application :

$ forever start server.js

This starts the server and gives an id for the process(starts from 0).

Restart application :

$ forever restart 0

Here 0 is the id of the server.

Stop application :

$ forever stop 0

Similar to restart, 0 is the id the server. You can also give process id or script name in place of the id given by the forever.

For more commands : https://www.npmjs.com/package/forever



Got any Node.js Question?