Graceful Shutdown and Health Checks

A host stops your API with SIGTERM on every deploy, so a graceful shutdown stops taking new requests, lets the ones in progress finish with server.close, then closes MongoDB, and a /health route answers 200 or 503 so the host knows whether to send the API riders.

By

Updated

Cheat sheet: Graceful Shutdown and Health Checks
Category
Node.js
Level
Freelancer
Tags
503 Service Unavailable, Graceful Shutdown (nodejs), Health Check (rest-api), nodejs, Signal (unix), sigterm, web-development