DEV: Make rails_failover compatible with `SKIP_DB_AND_REDIS` env.

DEV: Make rails_failover compatible with SKIP_DB_AND_REDIS env.

diff --git a/app/models/global_setting.rb b/app/models/global_setting.rb
index dc660fc..4a6149f 100644
--- a/app/models/global_setting.rb
+++ b/app/models/global_setting.rb
@@ -163,7 +163,7 @@ class GlobalSetting
         c[:host] = redis_host if redis_host
         c[:port] = redis_port if redis_port
 
-        if redis_slave_host && redis_slave_port
+        if redis_slave_host && redis_slave_port && defined?(RailsFailover)
           c[:replica_host] = redis_slave_host
           c[:replica_port] = redis_slave_port
           c[:connector] = RailsFailover::Redis::Connector
diff --git a/config/initializers/002-rails_failover.rb b/config/initializers/002-rails_failover.rb
index 8826108..d414a86 100644
--- a/config/initializers/002-rails_failover.rb
+++ b/config/initializers/002-rails_failover.rb
@@ -1,6 +1,6 @@
 # frozen_string_literal: true
 
-if !GlobalSetting.skip_redis?
+if defined?(RailsFailover::Redis)
   message_bus_keepalive_interval = nil
 
   RailsFailover::Redis.on_failover do
@@ -16,7 +16,7 @@ if !GlobalSetting.skip_redis?
   end
 end
 
-if !GlobalSetting.skip_db?
+if defined?(RailsFailover::ActiveRecord)
   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 57ef2ae..e326e52 100644
--- a/config/initializers/200-first_middlewares.rb
+++ b/config/initializers/200-first_middlewares.rb
@@ -24,7 +24,10 @@ if Rails.configuration.multisite
   # Multisite needs to be first, because the request tracker and message bus rely on it
   Rails.configuration.middleware.unshift RailsMultisite::Middleware, RailsMultisite::DiscoursePatches.config
   Rails.configuration.middleware.delete ActionDispatch::Executor
-  Rails.configuration.middleware.insert_after(RailsMultisite::Middleware, RailsFailover::ActiveRecord::Middleware)
-else
+
+  if defined?(RailsFailover)
+    Rails.configuration.middleware.insert_after(RailsMultisite::Middleware, RailsFailover::ActiveRecord::Middleware)
+  end
+elsif defined?(RailsFailover)
   Rails.configuration.middleware.insert_before(MessageBus::Rack::Middleware, RailsFailover::ActiveRecord::Middleware)
 end

GitHub sha: 402b80f3