Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I kill job in Sidekiq took long to finish

I have jobs does it take more than 2h to finish. I want to put a time to limit how long it will take it. How do i can do?

like image 860
tenaz3.comp Avatar asked Aug 17 '14 20:08

tenaz3.comp


1 Answers

Wrap the logic with Timeout::timeout and disable retries if you don't want the job to be retried after a timeout.

class RunsTooLongWorker
  include Sidekiq::Worker

  sidekiq_options :retry => false

  def perform(*args)
    Timeout::timeout(2.hours) do
      # do possibly long running task
    end
  end
end
like image 106
infused Avatar answered Nov 13 '22 21:11

infused