27

I am unable to run the resque-web on my server due to some issues I still have to work on but I still have to check and retry failed jobs in my resque queues.

Has anyone any experience on how to peek the failed jobs queue to see what the error was and then how to retry it using the redis-cli command line?

thanks,

Horacio
  • 2,727
  • 5
  • 26
  • 29
  • 1
    It would be simpler to use a ruby console to do that since Resque has all kinds of helpers. Why would you want to do it directly in redis-cli? – marcgg Jan 12 '12 at 15:03
  • Thanks, solved my problem using the rails console as you recommended. – Horacio Jan 13 '12 at 05:40

1 Answers1

66

Found a solution on the following link:

http://ariejan.net/2010/08/23/resque-how-to-requeue-failed-jobs

In the rails console we can use these commands to check and retry failed jobs:

1 - Get the number of failed jobs:

 Resque::Failure.count

2 - Check the errors exception class and backtrace

Resque::Failure.all(0,20).each { |job|
   puts "#{job["exception"]}  #{job["backtrace"]}"
}

The job object is a hash with information about the failed job. You may inspect it to check more information. Also note that this only lists the first 20 failed jobs. Not sure how to list them all so you will have to vary the values (0, 20) to get the whole list.

3 - Retry all failed jobs:

(Resque::Failure.count-1).downto(0).each { |i| Resque::Failure.requeue(i) }

4 - Reset the failed jobs count:

 Resque::Failure.clear

retrying all the jobs do not reset the counter. We must clear it so it goes to zero.

Horacio
  • 2,727
  • 5
  • 26
  • 29
  • Don't forget that Resque also has a easily configurable web interface for viewing errors and their stack traces. See https://github.com/resque/resque for more info. – Peter Berg Jan 19 '15 at 15:43
  • 4
    To list all failed jobs, you can do this: `Resque::Failure.all(0,0)` – Leandro May 03 '16 at 14:22