buildout server module
This commit is contained in:
10
src/index.ts
10
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'));
|
||||
Reference in New Issue
Block a user