Ensuring uptime

We have seen that if a worker process crashes, a new one can be forked by the master process, while the remaining workers can handle the current requests. But what happens when the master process itself crashes?

Uptime concerns are a unique aspect of Node apps, but with proper knowledge and the right tools this concern can be addressed to satisfaction.

Let's look at two popular tools for ensuring Express apps are up and running, with as little downtime as possible.

Forever

Ensuring a Node app is restarted when it goes down can easily be accomplished with the help of a Node package called forever.

Install forever as global module, so that we can use it as a command-line tool:

$ npm install forever -g

After forever is installed, type ...

Get Express Web Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.