mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-29 07:26:28 +08:00
Add a startup check for WOPI_ENABLED == true variables
This commit is contained in:
parent
df59c54bd4
commit
4136aa0575
2 changed files with 22 additions and 1 deletions
|
|
@ -390,7 +390,7 @@ class Asset < ApplicationRecord
|
|||
action = get_action(file_ext, action)
|
||||
if !action.nil?
|
||||
action_url = action.urlsrc
|
||||
if ENV['WOPI_BUSINESS_USERS'] && ENV['WOPI_BUSINESS_USERS']=='true'
|
||||
if ENV['WOPI_BUSINESS_USERS'] && ENV['WOPI_BUSINESS_USERS'] == 'true'
|
||||
action_url = action_url.gsub(/<IsLicensedUser=BUSINESS_USER&>/,
|
||||
'IsLicensedUser=1&')
|
||||
action_url = action_url.gsub(/<IsLicensedUser=BUSINESS_USER>/,
|
||||
|
|
|
|||
21
config/initializers/wopi_startup_check.rb
Normal file
21
config/initializers/wopi_startup_check.rb
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Only check if connection works when server starts, and if WOPI is
|
||||
# enabled
|
||||
if defined? Rails::Server && 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
|
||||
|
||||
unless missing_vars.empty?
|
||||
puts "WARNING: Due to WOPI_ENABLED == 'true', " \
|
||||
"following env. variables MUST also be specified: " \
|
||||
"#{missing_vars.join(', ')}; " \
|
||||
"aborting."
|
||||
abort
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue