handle stop signal
This commit is contained in:
parent
b7907c94ae
commit
e5d559b75c
12
src/app.js
12
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user