diff --git a/src/app.js b/src/app.js index 5c94c1e..09bde4a 100644 --- a/src/app.js +++ b/src/app.js @@ -70,3 +70,15 @@ io.on('connection', async (socket) => { const server = http.listen(port, () => { console.log(`server is running on port ${server.address().port}`); }); + + +// handle stop signal +const shutdown = () => { + console.log('Stopping server.'); + process.exit(); + // server.close(() => { + // console.log('Stopped server.'); + // }); +}; +process.on('SIGINT', shutdown); +process.on('SIGTERM', shutdown);