diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-06-20 14:10:13 +0300 |
commit | 0ea3fcec397b69815975647f5e2aa5fe944a8486 (patch) | |
tree | 7979381b89d26011bcf9bdc989a40fcc2f1ed4ff /lib/gitlab/daemon.rb | |
parent | 72123183a20411a36d607d70b12d57c484394c8e (diff) |
Add latest changes from gitlab-org/gitlab@15-1-stable-eev15.1.0-rc42
Diffstat (limited to 'lib/gitlab/daemon.rb')
-rw-r--r-- | lib/gitlab/daemon.rb | 16 |
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 |