DEV: Only failover the entire cluster when the default db goes down.

This commit is contained in:
Guo Xiang Tan 2020-07-09 11:46:30 +08:00
parent 31e31ef449
commit d5c56a846a
No known key found for this signature in database
GPG Key ID: FBD110179AAC1F20
1 changed files with 5 additions and 3 deletions

View File

@ -31,9 +31,11 @@ if defined?(RailsFailover::ActiveRecord)
end
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?
if RailsMultisite::ConnectionManagement.current_db = RailsMultisite::ConnectionManagement::DEFAULT
RailsMultisite::ConnectionManagement.each_connection do
Discourse.enable_readonly_mode(Discourse::PG_READONLY_MODE_KEY)
Sidekiq.pause!("pg_failover") if !Sidekiq.paused?
end
end
end