Skip to content

Squiss.stop: Wait for currently running jobs to complete #29

@loris

Description

@loris

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions