Last active
September 11, 2019 19:44
-
-
Save CharlesP/1818418754aec03403b3 to your computer and use it in GitHub Desktop.
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
namespace :retry do | |
require 'rubygems' | |
desc 'Retry Resque DirtyExit jobs' | |
task resque_dirtyexit_jobs: :environment do | |
redis = Resque.redis | |
(0...Resque::Failure.count).each do |i| | |
serialized_job = redis.lindex(:failed, i) | |
job = Resque.decode(serialized_job) | |
next if job.nil? | |
if job['exception'] == 'Resque::DirtyExit' | |
puts "Retry #{job['payload']['class']}" | |
Resque::Failure.requeue(i) | |
Resque::Failure.remove(i) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment