Resque jobs, how to stop running job

Aydar Omurbekov picture Aydar Omurbekov · Nov 20, 2013 · Viewed 7.4k times · Source

My Resque worker class

class WebWorker

  @queue = :jobs_queue

  def self.perform(id)
  //bunch of code here
  end
end

I remove from the queue a certain job like this

Resque.dequeue(WebWorker,id)

But I would like to stop running job and restart, how would I do this?

Answer

joaofraga picture joaofraga · May 20, 2015

Try the unregister_worker as follow:

Resque.workers.each(&:unregister_worker)

This command will stop the work and set it as failed.

http://www.rubydoc.info/gems/resque/Resque/Worker:unregister_worker