Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-06-06 18:09:05 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-06-06 18:09:05 +0300
commitc79da5142f46e6e9187f75c329e2c81a8568c581 (patch)
treee1411c6a9b22582f91bfbca947c343d0b36cf11a /lib/gitlab/daemon.rb
parent2e31a394c5857fdb845811685ca7fc79a2fb7540 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/daemon.rb')
-rw-r--r--lib/gitlab/daemon.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/gitlab/daemon.rb b/lib/gitlab/daemon.rb
index 5f579f90629..04d13778499 100644
--- a/lib/gitlab/daemon.rb
+++ b/lib/gitlab/daemon.rb
@@ -2,10 +2,20 @@
module Gitlab
class Daemon
- def self.initialize_instance(...)
- raise "#{name} singleton instance already initialized" if @instance
+ # Options:
+ # - recreate: We usually only allow a single instance per process to exist;
+ # this can be overridden with this switch, so that existing
+ # instances are stopped and recreated.
+ def self.initialize_instance(*args, recreate: false, **options)
+ if @instance
+ if recreate
+ @instance.stop
+ else
+ raise "#{name} singleton instance already initialized"
+ end
+ end
- @instance = new(...)
+ @instance = new(*args, **options)
Kernel.at_exit(&@instance.method(:stop))
@instance
end