mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 09:12:45 +08:00
FEATURE: readonly safeguard
This commit is contained in:
parent
db53e022cc
commit
9a637836d0
|
@ -170,13 +170,24 @@ module Discourse
|
|||
end
|
||||
|
||||
def self.enable_readonly_mode
|
||||
$redis.set readonly_mode_key, 1
|
||||
$redis.set(readonly_mode_key, 1)
|
||||
MessageBus.publish(readonly_channel, true)
|
||||
keep_readonly_mode
|
||||
true
|
||||
end
|
||||
|
||||
def self.keep_readonly_mode
|
||||
# extend the expiry by 1 minute every 30 seconds
|
||||
Thread.new do
|
||||
while readonly_mode?
|
||||
$redis.expire(readonly_mode_key, 1.minute)
|
||||
sleep 30.seconds
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.disable_readonly_mode
|
||||
$redis.del readonly_mode_key
|
||||
$redis.del(readonly_mode_key)
|
||||
MessageBus.publish(readonly_channel, false)
|
||||
true
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user