Skip to content

Instantly share code, notes, and snippets.

@ajsharma
Last active February 28, 2017 23:41
Show Gist options
  • Save ajsharma/fdd9e91b9ddc0aeb45f6c2ce0ac5d065 to your computer and use it in GitHub Desktop.
Save ajsharma/fdd9e91b9ddc0aeb45f6c2ce0ac5d065 to your computer and use it in GitHub Desktop.
Resque retry with prompt
# Prompt the user for each failed Resque job
# Respond with `y` to retry, otherwise it's skipped
def triage
# Pop jobs off the queue until there are no more
Resque::Failure.all( 0, 0 ).each.with_index do |job, index|
puts "JOB:"
pp job.except( "backtrace" )
puts "Retry? ('y')"
input = gets.chomp.downcase
if "y" == input
Resque::Failure.requeue index
puts "pushed #{index}"
else
puts "not pushed #{index}"
end
puts
end
end
@ajsharma
Copy link
Author

WIP tweak to allow jobs to be removed

# Prompt the user for each failed Resque job 
# Respond with `y` to retry, otherwise it's skipped

def triage
  # Pop jobs off the queue until there are no more
  Resque::Failure.all( 0, 0 ).each.with_index do |job, index|
    puts "JOB:"
    pp job.except( "backtrace" )
    puts
  
    print "Retry? (y: yes, d: delete, n: no)> "

    case gets.chomp.downcase
    when "y"
      Resque::Failure.requeue index
      puts "pushed #{index}"
    when "d"
      Resque::Failure.remove index
      puts "deleting #{index}"
    else
      puts "skipped #{index}"
    end
    puts 
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment