Add a Redis environment variable for sidekiq (#16188)

master
Takeshi Umeda 4 years ago committed by GitHub
parent f9c2d1b9a1
commit 9b18914c35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      config/initializers/sidekiq.rb
  2. 12
      lib/mastodon/redis_config.rb

@ -1,14 +1,7 @@
# frozen_string_literal: true
namespace = ENV.fetch('REDIS_NAMESPACE') { nil }
redis_params = { url: ENV['REDIS_URL'], driver: :hiredis }
if namespace
redis_params[:namespace] = namespace
end
Sidekiq.configure_server do |config|
config.redis = redis_params
config.redis = REDIS_SIDEKIQ_PARAMS
config.server_middleware do |chain|
chain.add SidekiqErrorHandler
@ -26,7 +19,7 @@ Sidekiq.configure_server do |config|
end
Sidekiq.configure_client do |config|
config.redis = redis_params
config.redis = REDIS_SIDEKIQ_PARAMS
config.client_middleware do |chain|
chain.add SidekiqUniqueJobs::Middleware::Client

@ -22,9 +22,11 @@ end
setup_redis_env_url
setup_redis_env_url(:cache, false)
setup_redis_env_url(:sidekiq, false)
namespace = ENV.fetch('REDIS_NAMESPACE', nil)
cache_namespace = namespace ? namespace + '_cache' : 'cache'
namespace = ENV.fetch('REDIS_NAMESPACE', nil)
cache_namespace = namespace ? namespace + '_cache' : 'cache'
sidekiq_namespace = namespace
REDIS_CACHE_PARAMS = {
driver: :hiredis,
@ -32,3 +34,9 @@ REDIS_CACHE_PARAMS = {
expires_in: 10.minutes,
namespace: cache_namespace,
}.freeze
REDIS_SIDEKIQ_PARAMS = {
driver: :hiredis,
url: ENV['SIDEKIQ_REDIS_URL'],
namespace: sidekiq_namespace,
}.freeze

Loading…
Cancel
Save