Silverbolt
Silverbolt

Reputation: 7503

Re-queuing jobs with Resque

I am interested in using Resque to distribute work to many different computers. I have one concern though. If I need to kill one of the workers that is working on a job, I would like to be able to have it automatically requeue that job to ensure that it gets run by another worker. I've worked with Django Celery and just do CTRL+C which kills the worker as well as requeues the task. Is there a way for this to happen with Resque in Rails? Thank you!

Upvotes: 2

Views: 745

Answers (1)

Silverbolt
Silverbolt

Reputation: 7503

I just figured it out. I can trap the signal term (CTRL-C) and force it to either requeue the job or tell the job to fail and have resque-retry requeue the job at a later time.

For example:

def self.perform(args)
  trap("INT") do
     puts "Signal was caught!"
     #either raise an error here if using a tool like resque-retry or requeue the job
   end
  #Do work here
end

Sorry for the silly question ;)

Upvotes: 3

Related Questions