Skip to content

Instantly share code, notes, and snippets.

@CharlesP
Last active September 11, 2019 19:44
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save CharlesP/1818418754aec03403b3 to your computer and use it in GitHub Desktop.
Save CharlesP/1818418754aec03403b3 to your computer and use it in GitHub Desktop.
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