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>2019-12-27 21:08:12 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-27 21:08:12 +0300
commit41c9fff024a72e6581e71c2ae080bdcb961a5601 (patch)
treeb36a268efbaee403fa424048f030d5e281dcfbf8 /lib/gitlab/runtime.rb
parentfb73ca3398c2ac49a616ab553e117b0586089702 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/runtime.rb')
-rw-r--r--lib/gitlab/runtime.rb19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/gitlab/runtime.rb b/lib/gitlab/runtime.rb
index 33b7b68e64e..c9e5d71c107 100644
--- a/lib/gitlab/runtime.rb
+++ b/lib/gitlab/runtime.rb
@@ -4,8 +4,9 @@ module Gitlab
# Provides routines to identify the current runtime as which the application
# executes, such as whether it is an application server and which one.
module Runtime
- AmbiguousProcessError = Class.new(StandardError)
- UnknownProcessError = Class.new(StandardError)
+ IdentificationError = Class.new(RuntimeError)
+ AmbiguousProcessError = Class.new(IdentificationError)
+ UnknownProcessError = Class.new(IdentificationError)
class << self
def identify
@@ -14,6 +15,8 @@ module Gitlab
matches << :unicorn if unicorn?
matches << :console if console?
matches << :sidekiq if sidekiq?
+ matches << :rake if rake?
+ matches << :rspec if rspec?
if matches.one?
matches.first
@@ -41,6 +44,14 @@ module Gitlab
!!(defined?(::Sidekiq) && Sidekiq.server?)
end
+ def rake?
+ !!(defined?(::Rake) && Rake.application.top_level_tasks.any?)
+ end
+
+ def rspec?
+ Rails.env.test? && process_name == 'rspec'
+ end
+
def console?
!!defined?(::Rails::Console)
end
@@ -52,6 +63,10 @@ module Gitlab
def multi_threaded?
puma? || sidekiq?
end
+
+ def process_name
+ File.basename($0)
+ end
end
end
end