2019-08-01 11:50:03 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-03-09 14:33:50 +01:00
|
|
|
require 'sidekiq'
|
|
|
|
require 'sidekiq-scheduler'
|
|
|
|
|
2019-08-01 11:50:03 +02:00
|
|
|
redis_host = ENV['REDIS_HOST'] || 'localhost'
|
2016-03-23 18:39:41 +01:00
|
|
|
redis_url = "redis://#{redis_host}:6379"
|
|
|
|
|
2015-05-05 03:10:25 +02:00
|
|
|
Sidekiq.configure_server do |config|
|
2020-06-09 16:23:07 +02:00
|
|
|
config.redis = { url: redis_url }
|
2015-05-05 03:10:25 +02:00
|
|
|
|
2022-03-09 11:29:30 +01:00
|
|
|
config.client_middleware do |chain|
|
|
|
|
chain.add SidekiqUniqueJobs::Middleware::Client
|
|
|
|
end
|
|
|
|
|
|
|
|
config.server_middleware do |chain|
|
|
|
|
chain.add SidekiqUniqueJobs::Middleware::Server
|
|
|
|
end
|
|
|
|
|
|
|
|
SidekiqUniqueJobs::Server.configure(config)
|
|
|
|
|
2022-03-09 14:33:50 +01:00
|
|
|
config.on(:startup) do
|
|
|
|
# load sidekiq-scheduler schedule config
|
|
|
|
schedule_file = 'config/schedule.yml'
|
|
|
|
if File.exist?(schedule_file)
|
|
|
|
rendered_schedule_file = ERB.new(File.read(schedule_file)).result
|
|
|
|
Sidekiq.schedule = YAML.safe_load(rendered_schedule_file)
|
|
|
|
SidekiqScheduler::Scheduler.instance.reload_schedule!
|
|
|
|
end
|
2016-03-23 18:39:41 +01:00
|
|
|
end
|
|
|
|
end
|
2015-05-05 03:10:25 +02:00
|
|
|
|
2016-03-23 18:39:41 +01:00
|
|
|
Sidekiq.configure_client do |config|
|
2020-06-09 16:23:07 +02:00
|
|
|
config.redis = { url: redis_url }
|
2022-03-09 11:29:30 +01:00
|
|
|
|
|
|
|
config.client_middleware do |chain|
|
|
|
|
chain.add SidekiqUniqueJobs::Middleware::Client
|
|
|
|
end
|
2015-05-05 03:10:25 +02:00
|
|
|
end
|
2019-08-01 11:50:03 +02:00
|
|
|
|
2020-09-01 10:59:57 +02:00
|
|
|
# Quieting logging in the test environment
|
|
|
|
if Rails.env.test?
|
|
|
|
require 'sidekiq/testing'
|
|
|
|
Sidekiq.logger.level = Logger::ERROR
|
|
|
|
end
|