Created
January 30, 2014 11:11
-
-
Save mehdi-farsi/8706536 to your computer and use it in GitHub Desktop.
Requeue failed job
This file contains 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 :resque do | |
nemaspace :failed_job do | |
desc 'restart the N latest failed jobs and remove them from failed jobs queue.' | |
task :restart, [:n_latest] => [:environment] do |t, args| | |
args.with_defaults(n_latest: 20) | |
start_at = Resque::Failure.count - args[:n_latest] - 1 | |
finished_at = Resque::Failure.count - 1 | |
(start_at..finished_at).each do |index| | |
Resque::Failure.requeue_and_remove(index) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment