Quit on SIGINT & SIGTERM (added, Docker)

This commit is contained in:
Wietse Wind
2023-10-08 00:36:03 +02:00
parent 418c3680e0
commit 2e06c852f1
3 changed files with 15 additions and 6 deletions

View File

@@ -101,12 +101,15 @@ if (!wss) {
const server = app.listen(port || 3000)
// Play nice with Docker etc.
process.on('SIGINT', () => {
const quit = () => {
console.log('Shutting down webserver')
wss.getWss().clients.forEach(client => client.close())
server.close()
wss.getWss().close()
})
}
process.on('SIGINT', quit) // Node
process.on('SIGTERM', quit) // Docker
console.log('Started Event Socket Service at TCP port', port)
} catch (e) {