LearnBoost/kue — pull request #121 by runningskull (2012-07-30 23:55:40+00:00)
Title: Graceful Shutdown [isolated commits]

Hey TJ, I freakin' love Kue. Thanks for it!

This pull request is to implement a graceful shutdown procedure. I copied most of this code directly from #61, which is great, but has become entangled w/ too many unrelated changes. This request will _only_ contain patches related to graceful shutdown.

In addition, I added in an optional timeout, after which active jobs will be marked 'failed', and the process will shut down immediately.

Here's the use case, which I'd argue is a common one: when we deploy a new version of a worker, we first kill the running process w/ a SIGTERM before starting it again w/ the new codebase. I needed a way to shut down w/ the least possible hassle, and w/out failing any jobs if we can help it.

I'd really like to see this merged. Let's discuss if anything's holding it back, or isn't quite right.