[arvados] created: 2.5.0-219-gc74be2450
git repository hosting
git at public.arvados.org
Thu Mar 2 23:46:04 UTC 2023
at c74be245074e7dc71cd43dd856a5c425513e4857 (commit)
commit c74be245074e7dc71cd43dd856a5c425513e4857
Author: Tom Clegg <tom at curii.com>
Date: Thu Mar 2 18:41:21 2023 -0500
20198: Run config-watcher thread in a worker process, not preloader.
See https://www.phusionpassenger.com/library/indepth/ruby/spawn_methods/
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>
diff --git a/apps/workbench/config/initializers/reload_config.rb b/apps/workbench/config/initializers/reload_config.rb
index 6c5632e05..ec6db0c0e 100644
--- a/apps/workbench/config/initializers/reload_config.rb
+++ b/apps/workbench/config/initializers/reload_config.rb
@@ -6,11 +6,7 @@
# 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|
@@ -68,3 +64,15 @@ else
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
diff --git a/services/api/config/initializers/reload_config.rb b/services/api/config/initializers/reload_config.rb
index bdc815099..b54e3bcf8 100644
--- a/services/api/config/initializers/reload_config.rb
+++ b/services/api/config/initializers/reload_config.rb
@@ -2,11 +2,10 @@
#
# 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|
@@ -64,3 +63,15 @@ else
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
commit b591db2f50566d617282d15f006ce5d64a7a63a0
Author: Tom Clegg <tom at curii.com>
Date: Thu Mar 2 17:57:32 2023 -0500
20198: Fix unclosed response body.
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>
diff --git a/lib/controller/rails_restart_test.go b/lib/controller/rails_restart_test.go
index 5db37c4b8..e3267c220 100644
--- a/lib/controller/rails_restart_test.go
+++ b/lib/controller/rails_restart_test.go
@@ -79,9 +79,11 @@ func (s *railsRestartSuite) TestConfigReload(c *check.C) {
for deadline := time.Now().Add(20 * time.Second); time.Now().Before(deadline); time.Sleep(time.Second) {
resp, err = hc.Do(req)
c.Assert(err, check.IsNil)
+ defer resp.Body.Close()
c.Check(resp.StatusCode, check.Equals, http.StatusOK)
body, err = ioutil.ReadAll(resp.Body)
c.Assert(err, check.IsNil)
+ resp.Body.Close()
if strings.Contains(string(body), newhash) {
break
}
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list