DEV: Add force rails_over switch via Redis.

This commit is contained in:
Guo Xiang Tan 2020-06-01 11:23:58 +08:00
parent df62407f35
commit b0b37bf5a3
No known key found for this signature in database
GPG Key ID: FBD110179AAC1F20
1 changed files with 8 additions and 1 deletions

View File

@ -11,7 +11,14 @@ if ENV["ACTIVE_RECORD_RAILS_FAILOVER"]
Sidekiq.unpause!
end
module Discourse
PG_FORCE_READONLY_MODE_KEY ||= 'readonly_mode:postgres_force'
end
RailsFailover::ActiveRecord.register_force_reading_role_callback do
Discourse.pg_readonly_mode?
Discourse.redis.exists(
Discourse::PG_READONLY_MODE_KEY,
Discourse::PG_FORCE_READONLY_MODE_KEY
)
end
end