bkeepers / qu

a Ruby library for queuing and processing background jobs.
MIT License
506 stars 50 forks source link

Graceful shutdown #60

Closed dwbutler closed 10 years ago

dwbutler commented 11 years ago

This pull request implements graceful shutdown for Qu workers. I needed to make the change because when a worker aborts, it sometimes wouldn't be able to re-queue the job into the failure queue due to the Mongoid connection already being closed. So jobs would mysteriously go missing.

Features:

dwbutler commented 11 years ago

Okay, I think this should do it.

The worker rake task should exit normally with code 0 if it breaks out of a sleep or exits gracefully. It will only exit abnormally with code 1 if it aborts a currently running job.

dwbutler commented 10 years ago

Nice! I had given up all hope on this.

jnunemaker commented 10 years ago

@dwbutler fear not! :) Hoping to get a few more things together and cut a beta. We'll see.