reload the page when read_only mode is disabled

This commit is contained in:
Régis Hanol 2014-02-14 00:27:25 +01:00
parent 41d16a3657
commit a8b3269fdb
3 changed files with 14 additions and 9 deletions

View File

@ -30,8 +30,13 @@ Discourse.addInitializer(function() {
Discourse.MessageBus.subscribe("/global/read-only", function (enabled) { Discourse.MessageBus.subscribe("/global/read-only", function (enabled) {
Discourse.set("isReadOnly", enabled); Discourse.set("isReadOnly", enabled);
if (enabled && !Discourse.User.currentProp("hideReadOnlyAlert")) { if (enabled) {
bootbox.alert(I18n.t("read_only_mode.enabled")); if (!Discourse.User.currentProp("hideReadOnlyAlert")) {
bootbox.alert(I18n.t("read_only_mode.enabled"));
}
} else {
// force a reload
document.location.reload();
} }
}); });

View File

@ -149,9 +149,13 @@ module BackupRestore
end end
def self.after_fork def self.after_fork
# reconnect to redis
$redis.client.reconnect $redis.client.reconnect
# reconnect the rails cache (uses redis)
Rails.cache.reconnect Rails.cache.reconnect
# tells the message we've forked
MessageBus.after_fork MessageBus.after_fork
# /!\ HACK /!\ force sidekiq to create a new connection to redis
Sidekiq.instance_variable_set(:@redis, nil) Sidekiq.instance_variable_set(:@redis, nil)
end end

View File

@ -38,17 +38,13 @@ module Import
validate_metadata validate_metadata
extract_dump extract_dump
restore_dump restore_dump
#----------- CRITICAL --------------
switch_schema! switch_schema!
#----------- CRITICAL --------------
log "Finalizing restore..." # TOFIX: MessageBus is busted...
migrate_database migrate_database
reconnect_database reconnect_database
extract_uploads extract_uploads
@ -268,10 +264,10 @@ module Import
def rollback def rollback
log "Trying to rollback..." log "Trying to rollback..."
if BackupRestore.can_rollback? if BackupRestore.can_rollback?
log "Rolling back to previous working state..." log "Rolling back..."
BackupRestore.rename_schema("backup", "public") BackupRestore.rename_schema("backup", "public")
else else
log "No backup schema was created yet!" log "There was no need to rollback"
end end
end end