diff --git a/config/initializers/002-rails_failover.rb b/config/initializers/002-rails_failover.rb index 16c5dc4bdaa..a7529a08253 100644 --- a/config/initializers/002-rails_failover.rb +++ b/config/initializers/002-rails_failover.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -return unless Rails.configuration.active_record_rails_failover - if defined?(RailsFailover::Redis) message_bus_keepalive_interval = nil @@ -19,6 +17,8 @@ if defined?(RailsFailover::Redis) end if defined?(RailsFailover::ActiveRecord) + return unless Rails.configuration.active_record_rails_failover + if Rails.configuration.multisite if ActiveRecord::Base.current_role == ActiveRecord::Base.reading_role RailsMultisite::ConnectionManagement.default_connection_handler = diff --git a/config/initializers/200-first_middlewares.rb b/config/initializers/200-first_middlewares.rb index 3f2bce1458a..2467202d6e3 100644 --- a/config/initializers/200-first_middlewares.rb +++ b/config/initializers/200-first_middlewares.rb @@ -25,9 +25,9 @@ if Rails.configuration.multisite Rails.configuration.middleware.unshift RailsMultisite::Middleware, RailsMultisite::DiscoursePatches.config Rails.configuration.middleware.delete ActionDispatch::Executor - if defined?(RailsFailover) && Rails.configuration.active_record_rails_failover + if defined?(RailsFailover::ActiveRecord) && Rails.configuration.active_record_rails_failover Rails.configuration.middleware.insert_after(RailsMultisite::Middleware, RailsFailover::ActiveRecord::Middleware) end -elsif defined?(RailsFailover) && Rails.configuration.active_record_rails_failover +elsif defined?(RailsFailover::ActiveRecord) && Rails.configuration.active_record_rails_failover Rails.configuration.middleware.insert_before(MessageBus::Rack::Middleware, RailsFailover::ActiveRecord::Middleware) end