express: New expressCloseServer hook

This will be used by a future commit to close all socket.io
connections during server restart.
This commit is contained in:
Richard Hansen 2020-12-14 15:48:13 -05:00
parent 3e8c3e5789
commit 8c1afc3399
2 changed files with 23 additions and 1 deletions

View file

@ -20,7 +20,10 @@ exports.server = null;
const closeServer = async () => {
if (exports.server == null) return;
logger.info('Closing HTTP server...');
await util.promisify(exports.server.close.bind(exports.server))();
await Promise.all([
util.promisify(exports.server.close.bind(exports.server))(),
hooks.aCallAll('expressCloseServer'),
]);
exports.server = null;
logger.info('HTTP server closed');
};