Reduce job queue shutdown timeout

This commit is contained in:
Fedor Indutny 2023-04-05 16:37:25 -07:00 committed by GitHub
parent 4a18667ddf
commit c5dda1d62d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -740,11 +740,13 @@ export async function startApp(): Promise<void> {
sleeper.shutdown(); sleeper.shutdown();
const shutdownQueues = async () => { const shutdownQueues = async () => {
log.info('background/shutdown: shutting down queues');
await Promise.allSettled([ await Promise.allSettled([
StartupQueue.shutdown(), StartupQueue.shutdown(),
shutdownAllJobQueues(), shutdownAllJobQueues(),
]); ]);
log.info('background/shutdown: shutting down conversation queues');
await Promise.allSettled( await Promise.allSettled(
window.ConversationController.getAll().map(async convo => { window.ConversationController.getAll().map(async convo => {
try { try {
@ -757,9 +759,11 @@ export async function startApp(): Promise<void> {
} }
}) })
); );
log.info('background/shutdown: all queues shutdown');
}; };
// wait for at most 2 minutes for startup queue and job queues to drain // wait for at most 1 minutes for startup queue and job queues to drain
let timeout: NodeJS.Timeout | undefined; let timeout: NodeJS.Timeout | undefined;
await Promise.race([ await Promise.race([
shutdownQueues(), shutdownQueues(),
@ -770,7 +774,7 @@ export async function startApp(): Promise<void> {
); );
timeout = undefined; timeout = undefined;
resolve(); resolve();
}, 2 * MINUTE); }, 1 * MINUTE);
}), }),
]); ]);
if (timeout) { if (timeout) {