Skip to content

Instantly share code, notes, and snippets.

@nathmisaki
Forked from clemens/resque_retry.rb
Last active December 30, 2016 19:01
Show Gist options
  • Select an option

  • Save nathmisaki/df4f1790fa08b58b2528 to your computer and use it in GitHub Desktop.

Select an option

Save nathmisaki/df4f1790fa08b58b2528 to your computer and use it in GitHub Desktop.
Resque 1.x Swiss Army Tool
# 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