DEV: Pausing Sidekiq is multisite aware.

DEV: Pausing Sidekiq is multisite aware.

diff --git a/config/initializers/002-rails_failover.rb b/config/initializers/002-rails_failover.rb
index 570248c..383dca3 100644
--- a/config/initializers/002-rails_failover.rb
+++ b/config/initializers/002-rails_failover.rb
@@ -15,17 +15,15 @@ if ENV["ACTIVE_RECORD_RAILS_FAILOVER"]
   RailsFailover::ActiveRecord.on_failover do
     RailsMultisite::ConnectionManagement.each_connection do
       Discourse.enable_readonly_mode(Discourse::PG_READONLY_MODE_KEY)
+      Sidekiq.pause!("pg_failover") if !Sidekiq.paused?
     end
-
-    Sidekiq.pause!("pg_failover") if !Sidekiq.paused?
   end
 
   RailsFailover::ActiveRecord.on_fallback do
     RailsMultisite::ConnectionManagement.each_connection do
       Discourse.disable_readonly_mode(Discourse::PG_READONLY_MODE_KEY)
+      Sidekiq.unpause! if Sidekiq.paused?
     end
-
-    Sidekiq.unpause! if Sidekiq.pause?
   end
 
   module Discourse

GitHub sha: 54f79ea3

1 Like