1
0
Fork 0
forked from fedi/mastodon

Add a Redis environment variable for sidekiq (#16188)

This commit is contained in:
Takeshi Umeda 2021-05-09 17:40:17 +09:00 committed by GitHub
parent f9c2d1b9a1
commit 9b18914c35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 11 deletions

View file

@ -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

View file

@ -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