server: Refactor stop() to avoid no-async-promise-executor lint error

Also log when Etherpad has stopped.
This commit is contained in:
Richard Hansen 2020-12-22 01:01:37 -05:00 committed by John McLear
parent d339f2a671
commit 725023fe58

View file

@ -106,12 +106,15 @@ exports.stop = async () => {
if (stopped) return;
stopped = true;
console.log('Stopping Etherpad...');
await new Promise(async (resolve, reject) => {
const id = setTimeout(() => reject(new Error('Timed out waiting for shutdown tasks')), 3000);
await hooks.aCallAll('shutdown');
clearTimeout(id);
resolve();
});
let timeout = null;
await Promise.race([
hooks.aCallAll('shutdown'),
new Promise((resolve, reject) => {
timeout = setTimeout(() => reject(new Error('Timed out waiting for shutdown tasks')), 3000);
}),
]);
clearTimeout(timeout);
console.log('Etherpad stopped');
};
exports.exit = async (err) => {