close server when sigterm
This commit is contained in:
parent
391bb0b2d0
commit
46fb01d336
1 changed files with 16 additions and 9 deletions
|
@ -47,22 +47,29 @@ AppDataSource.initialize()
|
||||||
});
|
});
|
||||||
|
|
||||||
const port = config.get<number>('port');
|
const port = config.get<number>('port');
|
||||||
app.listen(port);
|
const server = app.listen(port);
|
||||||
logger.info(`Server started on port: ${port}`)
|
logger.info(`Server started on port: ${port}`)
|
||||||
|
|
||||||
await MatterbridgeManager.spawnAll();
|
await MatterbridgeManager.spawnAll();
|
||||||
let proclist = await MatterbridgeManager.processes;
|
let proclist = await MatterbridgeManager.processes;
|
||||||
logger.info('Spawned group processes: %s', proclist);
|
logger.info('Spawned group processes: %s', proclist);
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
// Kill matterbridge processes on app exit.
|
|
||||||
|
|
||||||
|
// Register signal handlers
|
||||||
process.on('SIGTERM', () => {
|
process.on('SIGTERM', () => {
|
||||||
logger.debug('killing matterbridge from SIGTERM')
|
logger.debug('killing matterbridge from SIGTERM')
|
||||||
killMatterbridge()
|
killMatterbridge()
|
||||||
|
server.close()
|
||||||
|
process.exit(0)
|
||||||
})
|
})
|
||||||
process.on('exit', () => {
|
process.on('exit', () => {
|
||||||
logger.debug('killing matterbridge from exit event')
|
logger.debug('killing matterbridge from exit event')
|
||||||
killMatterbridge()
|
killMatterbridge()
|
||||||
|
server.close()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
// Kill matterbridge processes on app exit.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue