mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 10:57:04 +08:00
DEV: Add REDIS_RAILS_FAILOVER
env to test our new redis failover.
This commit is contained in:
parent
deb84017f2
commit
439db7ca1e
|
@ -1,6 +1,6 @@
|
|||
GIT
|
||||
remote: https://github.com/discourse/rails_failover
|
||||
revision: 291bf1c18e9a704556a40204d8160549d0438e96
|
||||
revision: 73ceb21624079e007a7d3bf0bf201f0b34dcd6aa
|
||||
specs:
|
||||
rails_failover (0.4.0)
|
||||
activerecord (~> 6.0)
|
||||
|
|
|
@ -169,9 +169,15 @@ class GlobalSetting
|
|||
c[:port] = redis_port if redis_port
|
||||
|
||||
if redis_slave_host && redis_slave_port
|
||||
c[:slave_host] = redis_slave_host
|
||||
c[:slave_port] = redis_slave_port
|
||||
c[:connector] = DiscourseRedis::Connector
|
||||
if ENV["REDIS_RAILS_FAILOVER"]
|
||||
c[:replica_host] = redis_slave_host
|
||||
c[:replica_port] = redis_slave_port
|
||||
c[:connector] = RailsFailover::Redis::Connector
|
||||
else
|
||||
c[:slave_host] = redis_slave_host
|
||||
c[:slave_port] = redis_slave_port
|
||||
c[:connector] = DiscourseRedis::Connector
|
||||
end
|
||||
end
|
||||
|
||||
c[:password] = redis_password if redis_password.present?
|
||||
|
@ -193,9 +199,15 @@ class GlobalSetting
|
|||
c[:port] = message_bus_redis_port if message_bus_redis_port
|
||||
|
||||
if message_bus_redis_slave_host && message_bus_redis_slave_port
|
||||
c[:slave_host] = message_bus_redis_slave_host
|
||||
c[:slave_port] = message_bus_redis_slave_port
|
||||
c[:connector] = DiscourseRedis::Connector
|
||||
if ENV["REDIS_RAILS_FAILOVER"]
|
||||
c[:replica_host] = redis_slave_host
|
||||
c[:replica_port] = redis_slave_port
|
||||
c[:connector] = RailsFailover::Redis::Connector
|
||||
else
|
||||
c[:slave_host] = message_bus_redis_slave_host
|
||||
c[:slave_port] = message_bus_redis_slave_port
|
||||
c[:connector] = DiscourseRedis::Connector
|
||||
end
|
||||
end
|
||||
|
||||
c[:password] = message_bus_redis_password if message_bus_redis_password.present?
|
||||
|
|
|
@ -31,6 +31,10 @@ if ENV['ACTIVE_RECORD_RAILS_FAILOVER']
|
|||
require 'rails_failover/active_record'
|
||||
end
|
||||
|
||||
if ENV['REDIS_RAILS_FAILOVER']
|
||||
require 'rails_failover/redis'
|
||||
end
|
||||
|
||||
# Global config
|
||||
require_relative '../app/models/global_setting'
|
||||
GlobalSetting.configure!
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
if ENV["REDIS_RAILS_FAILOVER"]
|
||||
RailsFailover::Redis.on_failover do
|
||||
Discourse.received_redis_readonly!
|
||||
end
|
||||
|
||||
RailsFailover::Redis.on_fallback do
|
||||
Discourse.clear_readonly!
|
||||
Discourse.request_refresh!
|
||||
end
|
||||
end
|
||||
|
||||
if ENV["ACTIVE_RECORD_RAILS_FAILOVER"]
|
||||
RailsFailover::ActiveRecord.on_failover do
|
||||
RailsMultisite::ConnectionManagement.each_connection do
|
||||
|
|
|
@ -176,7 +176,10 @@ class DiscourseRedis
|
|||
STDERR.puts "WARN: Redis is in a readonly state. Performed a noop"
|
||||
end
|
||||
|
||||
fallback_handler.verify_master if !fallback_handler.master
|
||||
if !ENV["REDIS_RAILS_FAILOVER"]
|
||||
fallback_handler.verify_master if !fallback_handler.master
|
||||
end
|
||||
|
||||
Discourse.received_redis_readonly!
|
||||
nil
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue
Block a user