My new course Building a Production-Ready Service in Go is almost complete - try it out and let me know what you think!

Keeping NodeJS Applications Running Forever Using PM2

Elliot Forbes Elliot Forbes ⏰ 2 Minutes 📅 Apr 15, 2017

If you write an application that you need to keep running forever on your servers then this is the tutorial for you.

If you're a software developer working on business critical applications and have to adhere to strict Service Level Agreements (SLAs for short) then you know just how vital it is to have your applications back up and running the second they fall over, every second counts when trying to achieve the 5 9's or 99.999% availability throughout the year. In this tutorial I'll be demonstrating the effectiveness of PM2 which is a production process manager for Node.js applications which also features a built-in load balancer for those high-performance applications.

PM2 is an opensource bit of tech that's currently available here: and is currently owned and maintained by an Alexandre Strzelewicz from for those of you who want to check out his other work.

Installing PM2

PM2 doesn't require much configuration, if any, and if you've got NPM installed on your machine then installing PM2 is just a case of running the following command:

npm install pm2 -g

Once that's installed on your machine then you are then ready to go.

Starting an Application

Starting a node application that you want to keep running forever is as simple as this:

pm2 start app.js

More Info

PM2's official can be found here: should you wish to read up a bit more on this pretty amazing opensource tool and potentially thank the developers for their efforts.