CodeZettaInterview Hub

Node.js · Processes · Junior · Best Practice

How do you gracefully shut down a Node HTTP server?

Short Interview Answer

On SIGTERM: stop accepting, drain in-flight requests with a timeout, close DB pools, then exit.

Detailed Explanation

K8s sends SIGTERM before kill. readinessProbe should fail first. Force-exit after grace period.

Did you know this answer?