diff --git a/src/index.ts b/src/index.ts index af4f248..3976c92 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,3 +6,13 @@ const app = createApp(); const server = app.listen(PORT, () => { console.log(`Server running on http://localhost:${PORT}`); }); + +function shutdown(signal: string) { + console.log(`${signal} received — shutting down...`); + server.close(() => { + console.log('All connections closed. Exiting.'); + process.exit(0); + }); +} +process.on('SIGTERM', () => shutdown('SIGTERM')); +process.on('SIGINT', () => shutdown('SIGINT')); \ No newline at end of file