scinote-web/config/initializers/wopi_startup_check.rb

22 lines
624 B
Ruby
Raw Normal View History

# frozen_string_literal: true
# Only check if connection works when server starts, and if WOPI is
# enabled
if defined?(Rails::Server).present? && ENV['WOPI_ENABLED'] == 'true'
missing_vars = []
%w(
WOPI_TEST_ENABLED WOPI_DISCOVERY_URL WOPI_ENDPOINT_URL USER_SUBDOMAIN
WOPI_SUBDOMAIN WOPI_USER_HOST
).each do |var_name|
missing_vars << var_name if ENV[var_name].blank?
end
2021-07-23 17:56:28 +08:00
unless missing_vars.blank?
puts "WARNING: Due to WOPI_ENABLED == 'true', " \
"following env. variables MUST also be specified: " \
"#{missing_vars.join(', ')}; " \
"aborting."
abort
end
end