diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2022-04-28 17:47:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-28 17:47:34 +0200 |
commit | 3917353645b91dae04f7d9b81162fead6f73072a (patch) | |
tree | 202cbf93dfa378c26a291900ea65ec088ee5b5cc /config | |
parent | 9bf04db23acf10e05ffdf7def06c246081f8f065 (diff) |
Fix single Redis connection being used across all threads (#18135)
* Fix single Redis connection being used across all Sidekiq threads * Fix tests
Diffstat (limited to 'config')
-rw-r--r-- | config/application.rb | 2 | ||||
-rw-r--r-- | config/initializers/redis.rb | 14 | ||||
-rw-r--r-- | config/initializers/sidekiq.rb | 4 |
3 files changed, 4 insertions, 16 deletions
diff --git a/config/application.rb b/config/application.rb index a1ba71f61..64987cfe7 100644 --- a/config/application.rb +++ b/config/application.rb @@ -35,6 +35,7 @@ require_relative '../lib/paperclip/response_with_limit_adapter' require_relative '../lib/terrapin/multi_pipe_extensions' require_relative '../lib/mastodon/snowflake' require_relative '../lib/mastodon/version' +require_relative '../lib/mastodon/rack_middleware' require_relative '../lib/devise/two_factor_ldap_authenticatable' require_relative '../lib/devise/two_factor_pam_authenticatable' require_relative '../lib/chewy/strategy/custom_sidekiq' @@ -164,6 +165,7 @@ module Mastodon config.middleware.use Rack::Attack config.middleware.use Rack::Deflater + config.middleware.use Mastodon::RackMiddleware config.to_prepare do Doorkeeper::AuthorizationsController.layout 'modal' diff --git a/config/initializers/redis.rb b/config/initializers/redis.rb deleted file mode 100644 index 7573fc9f7..000000000 --- a/config/initializers/redis.rb +++ /dev/null @@ -1,14 +0,0 @@ -# frozen_string_literal: true - -redis_connection = Redis.new( - url: ENV['REDIS_URL'], - driver: :hiredis -) - -namespace = ENV.fetch('REDIS_NAMESPACE') { nil } - -if namespace - Redis.current = Redis::Namespace.new(namespace, redis: redis_connection) -else - Redis.current = redis_connection -end diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index 19a705ce8..c1327053d 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require_relative '../../lib/sidekiq_error_handler' +require_relative '../../lib/mastodon/sidekiq_middleware' Sidekiq.configure_server do |config| config.redis = REDIS_SIDEKIQ_PARAMS config.server_middleware do |chain| - chain.add SidekiqErrorHandler + chain.add Mastodon::SidekiqMiddleware end config.server_middleware do |chain| |