const shutdown = async () => {
log('Draining connections...');
await server.close();
await db.disconnect();
process.exit(0);
};
Graceful Shutdown Patterns for Node.js Services
The difference between a clean deploy and a 3 AM Slack message is often just a few lines of shutdown logic.