Does Sidekiq + Sidetiq repeat every 2 hours?

I cannot determine exactly how to establish a repeat rule to start a job every 2 hours. I currently have work to work at 3 o'clock every day (I think), using something similar in my Sidekiq working class:

recurrence do
  daily.hour_of_day(3)
end

What is the best way to make this run every 2 hours or every hour? I suppose it uses a gem icecubeunder the hood.

+4
source share
2 answers

Have you tried hourly(2)?

recurrence do
  hourly(2)
  # if you want to specify the exactly minute or minutes
  # `minute_of_hour(30, ...)`
  # hourly(2).minute_of_hour(30)
end

It is in the icecube README , but I have not tried it yet.

You can also do something like this:

recurrence do
  # set recurrence to [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]
  daily.hour_of_day(*(0..23).to_a.select { |hour_of_day| hour_of_day.even? })
end

hourly(2) - .

Sidetiq self.perform_in(2.hours) perform.

def perform
   # ...
   self.class.perform_in(2.hours)
end

UPDATE:

https://github.com/tobiassvn/sidetiq/wiki/Known-Issues

, ice_cube ( 100% - ) . , .

, :

recurrence { hourly.minute_of_hour(0, 15, 30, 45) }
+19

(2) - Ruby 2.0.0 ?

Sidetiq wiki -

" , Sidetiq Ruby 1.9.3. Ruby 2.0.0+ ."

, - , , , Ruby 2.0.0 , . . aledalgrande Pablo .

+2

All Articles