mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Create example of whenever integration, GH-66
This commit is contained in:
parent
1d92d1545e
commit
ef352f6b64
2 changed files with 38 additions and 1 deletions
37
examples/scheduling.rb
Normal file
37
examples/scheduling.rb
Normal file
|
@ -0,0 +1,37 @@
|
|||
# Sidekiq defers scheduling to other, better suited gems.
|
||||
# If you want to run a job regularly, here's an example
|
||||
# of using the 'whenever' gem to push jobs to Sidekiq
|
||||
# regularly.
|
||||
|
||||
class MyWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
def perform(count)
|
||||
puts "Job ##{count}: Late night, so tired..."
|
||||
end
|
||||
|
||||
def self.late_night_work
|
||||
10.times do |x|
|
||||
perform_async(x)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Kick off a bunch of jobs early in the morning
|
||||
every 1.day, :at => '4:30 am' do
|
||||
runner "MyWorker.late_night_work"
|
||||
end
|
||||
|
||||
|
||||
class HourlyWorker
|
||||
include Sidekiq::Worker
|
||||
|
||||
def perform
|
||||
cleanup_database
|
||||
format_hard_drive
|
||||
end
|
||||
end
|
||||
|
||||
every :hour do # Many shortcuts available: :hour, :day, :month, :year, :reboot
|
||||
runner "HourlyWorker.perform_async"
|
||||
end
|
|
@ -1,3 +1,3 @@
|
|||
module Sidekiq
|
||||
VERSION = "0.8.0"
|
||||
VERSION = "0.9.0"
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue