Clearing dead/stuck/zombie Resque workers
Problem
You see a bunch of workers running constantly event when there are no jobs in the queues.
Solution
In order to clear these, mark them done via rails console:
$ rails c
Loading development environment (Rails 3.1.3)
1.9.3p0 :002 > Resque::Worker.working.each{|w| w.done_working}
Written by Bashir Eghbali
Related protips
2 Responses
An oldie, but goodie. I never even considered it :) It's too bad current resque doesn't have a heartbeat mechanism.
https://github.com/shaiguitar/resque_stuck_queue/ is the heartbeat/watch approach resque doesn't have built-in. It doesn't automatically restart workers, but rather gives you the ability to configure it to do so. Alternatively send you a txt or whatever you want. It's helpful in cases where the queue is backed up as well. Been working well for me so far. From README:
If resque doesn't run jobs within a certain timeframe, it will trigger a pre-defined handler of your choice. You can use this to send an email, pager duty, add more resque workers, restart resque, send you a txt...whatever suits you.