log what happens at shutdown

This commit is contained in:
Zutatensuppe 2020-12-04 21:52:51 +01:00
parent ba62603576
commit 241e628b07

View file

@ -170,16 +170,27 @@ const server = app.listen(
wss.listen() wss.listen()
// persist games in fixed interval // persist games in fixed interval
setInterval(() => { const persistInterval = setInterval(() => {
console.log('Persisting games...'); console.log('Persisting games...');
Game.persistAll() Game.persistAll()
}, config.persistence.interval) }, config.persistence.interval)
const gracefulShutdown = (signal) => { const gracefulShutdown = (signal) => {
console.log(`${signal} received...`) console.log(`${signal} received...`)
console.log('clearing persist interval...')
clearInterval(persistInterval)
console.log('persisting games...')
Game.persistAll() Game.persistAll()
console.log('shutting down webserver...')
server.close() server.close()
console.log('shutting down websocketserver...')
wss.close() wss.close()
console.log('shutting down...')
process.exit() process.exit()
} }