mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 15:25:35 +08:00
FIX: Discourse.keep_readonly_mode
spins a new thread each time it is called.
This commit is contained in:
parent
6e97242bb9
commit
34e4c8f573
|
@ -294,10 +294,16 @@ module Discourse
|
|||
def self.keep_readonly_mode(key)
|
||||
# extend the expiry by 1 minute every 30 seconds
|
||||
unless Rails.env.test?
|
||||
Thread.new do
|
||||
while readonly_mode?(key)
|
||||
$redis.expire(key, READONLY_MODE_KEY_TTL)
|
||||
sleep 30.seconds
|
||||
@threads ||= {}
|
||||
|
||||
active_thread = @threads[key]
|
||||
|
||||
unless active_thread&.alive?
|
||||
@threads[key] = Thread.new do
|
||||
while readonly_mode?(key)
|
||||
$redis.expire(key, READONLY_MODE_KEY_TTL)
|
||||
sleep 30.seconds
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user