- Enable dynamic scheduling only if the schedule file exists - Update the sidekiq.yml to include a new job for batch generation - Define a cron schedule for the new job to run every 2 hours This update allows Sidekiq to conditionally enable its scheduler and introduces a new job that processes weather art batches every two hours. The change enhances the job management and scheduling dynamics in the application.
21 lines
612 B
Ruby
21 lines
612 B
Ruby
require "sidekiq"
|
|
require "sidekiq-scheduler"
|
|
|
|
Sidekiq.configure_server do |config|
|
|
config.redis = { url: ENV.fetch("REDIS_URL", "redis://localhost:6379/1") }
|
|
config.logger.level = Logger::INFO
|
|
config.on(:startup) do
|
|
schedule_file = "config/sidekiq.yml"
|
|
if File.exist?(schedule_file)
|
|
Sidekiq::Scheduler.enabled = true
|
|
Sidekiq::Scheduler.dynamic = true
|
|
Sidekiq.schedule = YAML.load_file(schedule_file)
|
|
Sidekiq::Scheduler.reload_schedule!
|
|
end
|
|
end
|
|
end
|
|
|
|
Sidekiq.configure_client do |config|
|
|
config.redis = { url: ENV.fetch("REDIS_URL", "redis://localhost:6379/1") }
|
|
end
|