Skip to content

Instantly share code, notes, and snippets.

@mehdi-farsi
Created January 30, 2014 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mehdi-farsi/8706536 to your computer and use it in GitHub Desktop.
Save mehdi-farsi/8706536 to your computer and use it in GitHub Desktop.
Requeue failed job
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