InterviewBuddy
All interview questions

How would you shut down an Express server gracefully?

Advanced

Answer

On termination, stop accepting new work, drain active requests within a deadline, close dependencies, and then exit.

Explanation

Include a forced-exit deadline so a stuck request cannot stall shutdown forever.

Example

SIGTERM → server.close() → drain requests → close database pool