Graceful Shutdown

noun

say it: “GRAYS-ful SHUT-down” /ˈɡreɪsfəl ˈʃʌtˌdaʊn/

Stopping a server in an orderly way: no new requests, the current ones finished, then its connections closed.

What is a graceful shutdown in Node?

A graceful shutdown stops a server without cutting anyone off: it stops taking new requests, lets the ones in progress finish, then closes the database. In Node it starts when the process gets a SIGTERM signal, which hosts send before they stop an app.

process.on("SIGTERM", () => {
  server.close(async () => {
    await client.close();
    process.exit(0);
  });
});

In a sentence

  • “Thanks to its graceful shutdown, the shuttle API finished every booking in progress before the new version took over.”
  • “Without a graceful shutdown, a deploy cut off a customer's payment halfway.”

Level: Freelancer · More Node.js terms at this level

Updated