-
-
Save nathmisaki/df4f1790fa08b58b2528 to your computer and use it in GitHub Desktop.
Resque 1.x Swiss Army Tool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # inspired by http://ariejan.net/2010/08/23/resque-how-to-requeue-failed-jobs | |
| # retry all failed Resque jobs except the ones that have already been retried | |
| # This is, for instance, useful if you have already retried some jobs via the web interface. | |
| Resque::Failure.each { |i, j| Resque::Failure.requeue(i) unless j['retried_at'].present? }; nil | |
| # retry all :) | |
| Resque::Failure.each { |i, j| Resque::Failure.requeue(i) }; nil | |
| # Clear retried jobs | |
| Resque::Failure.each { |i, j| Resque::Failure.remove(i) if j['retried_at'].present? }; nil | |
| # Check if a job exists | |
| Resque.redis.lrange("queue:#{queue}", 0, -1).find { |j| job = Resque.decode(j); job['class'] == <Class> && job['args'] == [<args>] } | |
| # Check if a job is running | |
| Resque.working.collect { |w| w.job }.find { |j| j['payload']['class'] == '<Class>' && j['payload']['args'] == [<args>] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment