1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-11 22:24:21 +01:00
fab-manager/config/initializers/sidekiq.rb
2022-03-09 11:29:30 +01:00

43 lines
1.0 KiB
Ruby

# frozen_string_literal: true
redis_host = ENV['REDIS_HOST'] || 'localhost'
redis_url = "redis://#{redis_host}:6379"
Sidekiq.configure_server do |config|
config.redis = { url: redis_url }
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)
# load sidekiq-cron schedule config
schedule_file = 'config/schedule.yml'
if File.exist?(schedule_file)
rendered_schedule_file = ERB.new(File.read(schedule_file)).result
Sidekiq::Cron::Job.load_from_hash YAML.safe_load(rendered_schedule_file)
end
end
Sidekiq.configure_client do |config|
config.redis = { url: redis_url }
config.client_middleware do |chain|
chain.add SidekiqUniqueJobs::Middleware::Client
end
end
Sidekiq::Extensions.enable_delay!
# Quieting logging in the test environment
if Rails.env.test?
require 'sidekiq/testing'
Sidekiq.logger.level = Logger::ERROR
end