DEV Community

Chandra Prakash Pal
Chandra Prakash Pal

Posted on • Edited on

PM2 Add NodeJs Project In Process List

During the NodeJs project deployment we use the PM2 as process manager.

PM2 monitor the application and restart it automatically while if app is crashing.

First install PM2 package

`$ npm install pm2@latest -g

or

$ yarn global add pm2`

When managing multiple applications with PM2, use a JS configuration file to organize them.

To generate a sample configuration file you can type this command:

pm2 init simple

This will generate a sample ecosystem.config.js:

module.exports = {
apps : [{
name : "app1",
script : "./app.js"
}]
}

Now the command to add NodeJs project in pm2 list with npm script are following way

pm2 start npm --name "{project_name}" -- run {script_name}

For Example ,let's i have a project with name HelloWorld and script to run the project are npm run dev the following command will be.

pm2 start npm --name "rStoreFront Backend" -- run dev

Here are some references for deploy nodejs project

How To Set Up Nginx Server Blocks (Virtual Hosts) on Ubuntu 16.04

https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-18-04

How To Set Up a Node.js Application for Production on Ubuntu 20.04

Heroku

Built for developers, by developers.

Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly — using the tools and languages you already love!

Learn More

Top comments (0)

Image of Quadratic

Free AI chart generator

Upload data, describe your vision, and get Python-powered, AI-generated charts instantly.

Try Quadratic free

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay