diff --git a/bin/webserver.mjs b/bin/webserver.mjs index aa497af..5e0dee4 100644 --- a/bin/webserver.mjs +++ b/bin/webserver.mjs @@ -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) { diff --git a/index.mjs b/index.mjs index 4d48416..0be9710 100644 --- a/index.mjs +++ b/index.mjs @@ -58,7 +58,7 @@ connections if (!sigintEventHandler) { sigintEventHandler = true - process.on('SIGINT', () => { + const quit = () => { connections .map(async c => { console.info('Interrupted', c.getState()?.server?.uri) @@ -71,5 +71,8 @@ if (!sigintEventHandler) { wtf.dump() console.log('-------------------' + `\n`) } - }) + } + + process.on('SIGINT', quit) // Node + process.on('SIGTERM', quit) // Docker } diff --git a/lib/events/ledgerReady.mjs b/lib/events/ledgerReady.mjs index 67b903b..fa30646 100644 --- a/lib/events/ledgerReady.mjs +++ b/lib/events/ledgerReady.mjs @@ -92,11 +92,14 @@ export { } // Play nice with Docker -process.on('SIGINT', () => { +const quit = () => { Object.values(ledgers).forEach(l => { clearTimeout(l?.timeout) l?.ledger_binary_transactions?.resolve(false) l?.ledger_info?.resolve(false) l?.vl?.resolve(false) }) -}) +} + +process.on('SIGINT', quit) // Node +process.on('SIGTERM', quit) // Docker