Squiss icon indicating copy to clipboard operation
Squiss copied to clipboard

Squiss.stop: Wait for currently running jobs to complete

Open loris opened this issue 8 years ago • 2 comments

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?

loris avatar Aug 25 '17 10:08 loris

Any update?

loris avatar Nov 01 '17 22:11 loris

@loris I have created an enhanced, typescriped library based on this one with your fix in it - https://github.com/PruvoNet/squiss-ts Please be aware that the api is not fully backwards compatible. Please let me know if that helps you

regevbr avatar Mar 10 '19 14:03 regevbr