Reputation: 6289
I am using sidekiq gem for process the background job and sidekiq-cron job to schedule the job at given time period.
#config/schedule.yml
my_first_job:
cron: "*/5 * * * *"
class: "HardWorker"
queue: hard_worker
I want to pass date (dynamic) as argument to the worker in schedule.yml.
Loading config/schedule.yml
#initializers/sidekiq.rb
schedule_file = "config/schedule.yml"
if File.exist?(schedule_file) && Sidekiq.server?
Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file)
end
job = Sidekiq::Cron::Job.find("my_first_job")
job.args = [Date.yesterday, Date.today]
When I find Sidekiq::Cron::Job.find("my_first_job")
, I see job is updated with date args. But I don't see the date at http://localhost:3000/sidekiq/cron
after I restart Sidekiq.
How to update args in Sidekiq cron job after loaded? Sidekiq::Cron::Job.load_from_hash YAML.load_file(schedule_file)
Upvotes: 3
Views: 1938