Search code examples
ruby-on-railsdelayed-jobresque

Resque jobs, how to stop running job


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?


Solution

  • 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