19139: Fixes bug by always setting owner_uuid to the system root user's UUID.
[arvados.git] / services / api / config / initializers / reload_config.rb
index 0698f92ca019bedae0d5b6898c6682e87e2c149d..1582855bfb29203a511546a3b7ec505dfee4658f 100644 (file)
@@ -47,7 +47,14 @@ else
           restartfile = Rails.root.join('tmp', 'restart.txt')
           touchtime = Time.now
           Rails.logger.info("reload_config: mtime on #{conffile} changed to #{t}, touching #{restartfile} to #{touchtime}")
-          File.utime(touchtime, touchtime, restartfile)
+          begin
+            File.utime(touchtime, touchtime, restartfile)
+          rescue
+            # remove + re-create works even if the existing file is
+            # owned by root, provided the tempdir is writable.
+            File.unlink(restartfile) rescue nil
+            File.open(restartfile, 'w') {}
+          end
           # Even if passenger doesn't notice that we hit restart.txt
           # and kill our process, there's no point waiting around to
           # hit it again.