Process Management & Reliability
5 min read
Module Overview
What You’ll Learn
- Explain what happens to a running Express app when an unhandled error crashes it
- Use Node’s built-in cluster module to run multiple worker processes
- Shut a process down gracefully, and use PM2 to keep it running automatically
💡 Why this matters:
node server.js, run directly in a terminal, dies the moment that terminal closes, or the moment an unhandled exception hits. Nothing in this course so far has needed to survive that, a production process does, every time, without a person watching it.
What’s Covered
- Why a single process isn’t enough, one uncaught exception, one crash, total downtime.
- The cluster module, running multiple worker processes on one machine, built into Node itself.
- Graceful shutdown, finishing in-flight requests before a process actually exits.
- PM2, a process manager that restarts a crashed application automatically, without a person intervening.
Hands-On
By the end of this module, you’ll have an application that survives a crash automatically, and makes use of more than one CPU core on the machine it runs on.
Next module: packaging that application into a container, so it runs identically anywhere.