diff --git a/packages/api/src/main.js b/packages/api/src/main.js index 8d352418..6b253a32 100644 --- a/packages/api/src/main.js +++ b/packages/api/src/main.js @@ -124,6 +124,18 @@ function start() { console.log('DbGate API listening on port', port); server.listen(port); } + + function shutdown() { + console.log('\nShutting down DbGate API server'); + server.close( ()=> { + console.log('Server shut down, terminating'); + process.exit(0); + }); + } + + process.on('SIGINT', shutdown); + process.on('SIGTERM', shutdown); + process.on('SIGBREAK', shutdown); } function useAllControllers(app, electron) {