DEV: Missing readonly mode banner when forcing PG readonly.

This commit is contained in:
Guo Xiang Tan 2020-06-01 12:12:24 +08:00
parent 27ad562ff5
commit 2c3ff3e524
No known key found for this signature in database
GPG Key ID: FBD110179AAC1F20
1 changed files with 10 additions and 0 deletions

View File

@ -13,6 +13,16 @@ if ENV["ACTIVE_RECORD_RAILS_FAILOVER"]
module Discourse
PG_FORCE_READONLY_MODE_KEY ||= 'readonly_mode:postgres_force'
READONLY_KEYS.push(PG_FORCE_READONLY_MODE_KEY)
def self.enable_pg_force_readonly_mode
Discourse.redis.set(PG_FORCE_READONLY_MODE_KEY, 1)
end
def self.disable_pg_force_readonly_mode
Discourse.redis.del(PG_FORCE_READONLY_MODE_KEY)
end
end
RailsFailover::ActiveRecord.register_force_reading_role_callback do