Created
October 20, 2012 21:18
-
-
Save teamon/3924858 to your computer and use it in GitHub Desktop.
clockwork + sidekiq integration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'clockwork' | |
require 'sidekiq' | |
# load all jobs from app/jobs directory | |
# no need to load rails env, we only care about classes | |
# (#perform method is not invoked in this process) | |
Dir["app/jobs/*"].each {|f| load f } | |
module Clockwork | |
every(1.day, 'midnight.job', :at => '00:00'){ | |
MidnightJob.perform_async(1,2,3) | |
} | |
end | |
Not a good choice skip rails if you are using different configuration for Redis.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that Sidekiq has a
perform_at
method, which might be more accurate because of polling times, etc. For maximum accuracy, I would rewrite the above as:which simply executes a minute before midnight, and schedules a job to be run at exactly midnight.