# services/api/config/initializers/reload_config.rb and update this
# copy. Or find a more reasonable way to share the code.
-if !File.owned?(Rails.root.join('tmp'))
- Rails.logger.debug("reload_config: not owner of #{Rails.root}/tmp, skipping")
-elsif ENV["ARVADOS_CONFIG"] == "none"
- Rails.logger.debug("reload_config: no config in use, skipping")
-else
+def start_reload_thread
Thread.new do
lockfile = Rails.root.join('tmp', 'reload_config.lock')
File.open(lockfile, File::WRONLY|File::CREAT, 0600) do |f|
end
end
end
+
+if !File.owned?(Rails.root.join('tmp'))
+ Rails.logger.debug("reload_config: not owner of #{Rails.root}/tmp, skipping")
+elsif ENV["ARVADOS_CONFIG"] == "none"
+ Rails.logger.debug("reload_config: no config in use, skipping")
+elsif defined?(PhusionPassenger)
+ PhusionPassenger.on_event(:starting_worker_process) do |forked|
+ start_reload_thread
+ end
+else
+ start_reload_thread
+end
#
# SPDX-License-Identifier: AGPL-3.0
-if !File.owned?(Rails.root.join('tmp'))
- Rails.logger.debug("reload_config: not owner of #{Rails.root}/tmp, skipping")
-elsif ENV["ARVADOS_CONFIG"] == "none"
- Rails.logger.debug("reload_config: no config in use, skipping")
-else
+# When updating this, please make the same changes in
+# apps/workbench/config/initializers/reload_config.rb as well.
+
+def start_reload_thread
Thread.new do
lockfile = Rails.root.join('tmp', 'reload_config.lock')
File.open(lockfile, File::WRONLY|File::CREAT, 0600) do |f|
end
end
end
+
+if !File.owned?(Rails.root.join('tmp'))
+ Rails.logger.debug("reload_config: not owner of #{Rails.root}/tmp, skipping")
+elsif ENV["ARVADOS_CONFIG"] == "none"
+ Rails.logger.debug("reload_config: no config in use, skipping")
+elsif defined?(PhusionPassenger)
+ PhusionPassenger.on_event(:starting_worker_process) do |forked|
+ start_reload_thread
+ end
+else
+ start_reload_thread
+end