2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-04-10 11:37:20 +02:00
|
|
|
SIDEKIQ_ENABLED = ENV.key?('REDIS_SIDEKIQ_SENTINELS') || ENV.key?('REDIS_URL') || ENV['RAILS_QUEUE_ADAPTER'] == 'sidekiq'
|
|
|
|
|
|
|
|
return if !SIDEKIQ_ENABLED
|
|
|
|
|
|
|
|
sidekiq_redis = if ENV.key?('REDIS_SIDEKIQ_SENTINELS')
|
2023-09-26 12:31:26 +02:00
|
|
|
name = ENV.fetch('REDIS_SIDEKIQ_MASTER')
|
|
|
|
username = ENV.fetch('REDIS_SIDEKIQ_USERNAME')
|
|
|
|
password = ENV.fetch('REDIS_SIDEKIQ_PASSWORD')
|
|
|
|
sentinels = ENV.fetch('REDIS_SIDEKIQ_SENTINELS')
|
|
|
|
.split(',')
|
|
|
|
.map { URI.parse(_1) }
|
|
|
|
.map { { host: _1.host, port: _1.port, username:, password: } }
|
|
|
|
|
2024-04-10 11:37:20 +02:00
|
|
|
{
|
|
|
|
name:,
|
|
|
|
sentinels:,
|
|
|
|
username:,
|
|
|
|
password:,
|
|
|
|
role: :master
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{} # default config from REDIS_URL
|
|
|
|
end
|
2024-03-28 11:25:37 +01:00
|
|
|
|
2024-04-10 11:37:20 +02:00
|
|
|
Sidekiq.configure_server do |config|
|
|
|
|
config.redis = sidekiq_redis
|
2024-04-02 17:35:21 +02:00
|
|
|
|
2024-04-10 11:37:20 +02:00
|
|
|
if ENV['PROMETHEUS_EXPORTER_ENABLED'] == 'enabled'
|
|
|
|
Yabeda.configure!
|
|
|
|
Yabeda::Prometheus::Exporter.start_metrics_server!
|
2023-09-26 12:31:26 +02:00
|
|
|
end
|
|
|
|
|
2024-04-10 11:37:20 +02:00
|
|
|
if ENV['SKIP_RELIABLE_FETCH'].blank?
|
|
|
|
Sidekiq::ReliableFetch.setup_reliable_fetch!(config)
|
2023-09-26 12:31:26 +02:00
|
|
|
end
|
|
|
|
end
|
2024-04-10 11:37:20 +02:00
|
|
|
|
|
|
|
Sidekiq.configure_client do |config|
|
|
|
|
config.redis = sidekiq_redis
|
|
|
|
end
|