Learn how to use pm2 to serve a Node.js app. PM2 is a super useful process management tool for Linux. The deployment/running of the application is already managed through the pm2 program. You can use pm2 list to see all the applications running now. Make sure you ssh as the Node.js user.
Published Mar 03, 2021
pm2 is a super useful process management tool for Linux.
I’ve used it for several projects of mine, and here I want to tell you how to use it too!
In particular I’m going to use it to run a Node.js app on a DigitalOcean VPS, and I’ll set it up so that whenever we push an update to the app’s GitHub repository, on the server pm2 will be pinged, and the app is going to be updated from GitHub and restarted.
Sounds cool? Let’s go!
First, sign up to DigitalOcean and follow my tutorial to create an VPS on DigitalOcean.
Important: use the `NodeJS_` image on DigitalOcean, which is already set up with `pm2_
_ and _node_`, and has a `nodejs_
_ user in addition to _root_`._
Once you’re up and running we can start.
Make sure you ssh as the
nodejs user. When you’re logged in as root, you can just run
su nodejs to use that user.
The sample Node.js app you have running in the VPS is in the folder
/var/www/html/, and it’s composed by the
The deployment/running of the application is already managed through the pm2 program, a daemon process manager.
You can use
pm2 list to see all the applications running now:
If you do any change to the application now, the changes won’t be applied until you restart the application running:
pm2 restart hello
Hire dedicated Node JS developers & programmers in India for custom full-stack NodeJS web development projects on hourly/full-time basis. Strict NDA, 16+ years exp & 2500+ clients|450+ Experts
Get business-centric Node.Js development services from expert Node.JS developers. We have expertise in developing & maintaining Node JS apps as per the business requirements.
SISGAIN is the top rated node js development company providing professional services on node js web and mobile development.
Get Node.js developers & programmers, and dedicated Node coders in India with average 5 years of experience. 15+ Yrs Exp, 500+ Staff, 13800+ Projects, 6800+ Clients.
Looking to hire Node js developers? One of the top Node js development companies in India & USA offers cost-effective Node js web development services.