mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 05:47:31 +08:00
FIX: Discourse.keep_readonly_mode
does not work for multisite.
This commit is contained in:
parent
1af7d4a894
commit
41c1e1b302
|
@ -294,15 +294,24 @@ module Discourse
|
|||
def self.keep_readonly_mode(key)
|
||||
# extend the expiry by 1 minute every 30 seconds
|
||||
unless Rails.env.test?
|
||||
@dbs ||= Set.new
|
||||
@dbs << RailsMultisite::ConnectionManagement.current_db
|
||||
@threads ||= {}
|
||||
|
||||
active_thread = @threads[key]
|
||||
|
||||
unless active_thread&.alive?
|
||||
unless @threads[key]&.alive?
|
||||
@threads[key] = Thread.new do
|
||||
while readonly_mode?(key)
|
||||
$redis.expire(key, READONLY_MODE_KEY_TTL)
|
||||
sleep 30.seconds
|
||||
while @dbs.size > 0
|
||||
@dbs.each do |db|
|
||||
RailsMultisite::ConnectionManagement.with_connection(db) do
|
||||
if readonly_mode?(key)
|
||||
$redis.expire(key, READONLY_MODE_KEY_TTL)
|
||||
else
|
||||
@dbs.delete(db)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
sleep 30
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user