Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inspect and retry resque jobs via redis-cli

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,

like image 904
Horacio Avatar asked Jan 10 '12 03:01

Horacio


1 Answers

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.

like image 52
Horacio Avatar answered Nov 20 '22 17:11

Horacio