mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 14:13:34 +01:00
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:
parent
3e8c3e5789
commit
8c1afc3399
2 changed files with 23 additions and 1 deletions
|
@ -76,6 +76,25 @@ Things in context:
|
|||
|
||||
This hook gets called after the application object has been created, but before it starts listening. This is similar to the expressConfigure hook, but it's not guaranteed that the application object will have all relevant configuration variables.
|
||||
|
||||
## expressCloseServer
|
||||
|
||||
Called from: src/node/hooks/express.js
|
||||
|
||||
Things in context: Nothing
|
||||
|
||||
This hook is called when the HTTP server is closing, which happens during
|
||||
shutdown (see the shutdown hook) and when the server restarts (e.g., when a
|
||||
plugin is installed via the `/admin/plugins` page). The HTTP server may or may
|
||||
not already be closed when this hook executes.
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
exports.expressCloseServer = async () => {
|
||||
await doSomeCleanup();
|
||||
};
|
||||
```
|
||||
|
||||
## eejsBlock_`<name>`
|
||||
Called from: src/node/eejs/index.js
|
||||
|
||||
|
|
|
@ -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');
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue