forked from External/greenlight
Added an env variable that allows maitenance mode (#679)
This commit is contained in:
parent
f2373ad21e
commit
02c0d577f8
|
@ -36,6 +36,9 @@ class ApplicationController < ActionController::Base
|
||||||
# Manually handle BigBlueButton errors
|
# Manually handle BigBlueButton errors
|
||||||
rescue_from BigBlueButton::BigBlueButtonException, with: :handle_bigbluebutton_error
|
rescue_from BigBlueButton::BigBlueButtonException, with: :handle_bigbluebutton_error
|
||||||
|
|
||||||
|
# Manually Handle errors when application is in readonly mode
|
||||||
|
rescue_from ActiveRecord::ReadOnlyRecord, with: :handle_readonly_error
|
||||||
|
|
||||||
protect_from_forgery with: :exception
|
protect_from_forgery with: :exception
|
||||||
|
|
||||||
MEETING_NAME_LIMIT = 90
|
MEETING_NAME_LIMIT = 90
|
||||||
|
@ -47,7 +50,7 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def maintenance_mode?
|
def maintenance_mode?
|
||||||
if ENV["MAINTENANCE_MODE"].present?
|
if ENV["MAINTENANCE_MODE"] == "full"
|
||||||
render "errors/greenlight_error", status: 503, formats: :html,
|
render "errors/greenlight_error", status: 503, formats: :html,
|
||||||
locals: {
|
locals: {
|
||||||
status_code: 503,
|
status_code: 503,
|
||||||
|
@ -190,4 +193,10 @@ class ApplicationController < ActionController::Base
|
||||||
def handle_bigbluebutton_error
|
def handle_bigbluebutton_error
|
||||||
render "errors/bigbluebutton_error"
|
render "errors/bigbluebutton_error"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Manually Handle errors when application is in readonly mode
|
||||||
|
def handle_readonly_error
|
||||||
|
flash.clear
|
||||||
|
redirect_to request.referrer, flash: { alert: I18n.t("errors.maintenance.readonly") }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,4 +22,8 @@ class ApplicationRecord < ActiveRecord::Base
|
||||||
def to_param
|
def to_param
|
||||||
uid
|
uid
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def readonly?
|
||||||
|
ENV["MAINTENANCE_MODE"] == "readonly"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -124,6 +124,7 @@ en:
|
||||||
maintenance:
|
maintenance:
|
||||||
message: Sorry, we're down for maintenance.
|
message: Sorry, we're down for maintenance.
|
||||||
help: We'll be back soon!
|
help: We'll be back soon!
|
||||||
|
readonly: This application is under maintenance. You will not be able to perform this action
|
||||||
migration_error:
|
migration_error:
|
||||||
contact_admin: If you are not an administrator, please contact one.
|
contact_admin: If you are not an administrator, please contact one.
|
||||||
continue: I'd like to stay using 1.0.
|
continue: I'd like to stay using 1.0.
|
||||||
|
|
|
@ -144,6 +144,14 @@ NUMBER_OF_ROWS=25
|
||||||
# ENABLE_GOOGLE_CALENDAR_BUTTON=true|false
|
# ENABLE_GOOGLE_CALENDAR_BUTTON=true|false
|
||||||
ENABLE_GOOGLE_CALENDAR_BUTTON=
|
ENABLE_GOOGLE_CALENDAR_BUTTON=
|
||||||
|
|
||||||
|
# Set the application into Maintenance Mode
|
||||||
|
#
|
||||||
|
# Current options supported:
|
||||||
|
# full: Renders an error page that does not allow users to access any of the features in the application
|
||||||
|
# readonly: Sets the database to readonly mode, which allows users to use actions that dont write to the database
|
||||||
|
# false: Application runs normally
|
||||||
|
MAINTENANCE_MODE=false
|
||||||
|
|
||||||
# Comment this out to send logs to STDOUT in production instead of log/production.log .
|
# Comment this out to send logs to STDOUT in production instead of log/production.log .
|
||||||
#
|
#
|
||||||
# RAILS_LOG_TO_STDOUT=true
|
# RAILS_LOG_TO_STDOUT=true
|
||||||
|
|
Loading…
Reference in New Issue