-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
My comprehension of the stop method is that it tells Squiss to stop polling/fetching new jobs, but it does nothing about currently running jobs.
To properly handle a graceful shutdown when the server stops (on SIGTERM signal), I think that the stop method should also accept a timeout param in ms and returns a Promise after all the running jobs are completed (or the timeout has expired). This way, we could have the following code:
// Handling graceful shutdown
const gracefulShutdown = () =>
myQueue.stop(true, 10000)
.then(() => process.exit(0));
process.on('SIGTERM', gracefulShutdown);
Jobs which are in the middle of their processing now have 10 additional seconds, to either complete their job, rollback some transactions, etc
What do you think?
Metadata
Metadata
Assignees
Labels
No labels