Commit d7d1295b authored by Matthias Kaeppler's avatar Matthias Kaeppler

Revert runtime ID to be based on just classes

parent 581b3020
......@@ -18,16 +18,16 @@ module Gitlab
end
def puma?
!!(defined?(::Puma) && bin == 'puma')
!!defined?(::Puma)
end
# For unicorn, we need to check for actual server instances to avoid false positives.
def unicorn?
!!(defined?(::Unicorn) && defined?(::Unicorn::HttpServer))
!!defined?(::Unicorn)
end
def sidekiq?
!!(defined?(::Sidekiq) && Sidekiq.server? && bin == 'sidekiq')
!!Sidekiq.server?
end
def console?
......@@ -41,22 +41,6 @@ module Gitlab
def multi_threaded?
puma? || sidekiq?
end
private
# Some example values from my system:
# puma: /data/cache/bundle-2.5/bin/puma
# unicorn: unicorn_rails master -E development -c /tmp/unicorn.rb -l 0.0.0.0:8080
# sidekiq: /data/cache/bundle-2.5/bin/sidekiq
# thin: bin/rails
# console: bin/rails
def script_name
$0
end
def bin
File.basename(script_name)
end
end
end
end
......@@ -3,12 +3,6 @@
require 'spec_helper'
describe Gitlab::Runtime do
REAL_PATH = $0
after(:all) do
$0 = REAL_PATH
end
context "when unknown" do
it "identifies as :unknown" do
expect(subject.name).to eq(:unknown)
......@@ -17,7 +11,6 @@ describe Gitlab::Runtime do
context "on multiple matches" do
before do
$0 = '/data/cache/bundle-2.5/bin/puma'
stub_const('::Puma', double)
stub_const('::Rails::Console', double)
end
......@@ -31,7 +24,6 @@ describe Gitlab::Runtime do
let(:puma_type) { double('::Puma') }
before do
$0 = '/data/cache/bundle-2.5/bin/puma'
stub_const('::Puma', puma_type)
end
......@@ -49,12 +41,9 @@ describe Gitlab::Runtime do
context "unicorn" do
let(:unicorn_type) { Module.new }
let(:unicorn_server_type) { Class.new }
before do
$0 = 'unicorn_rails master -E development -c /tmp/unicorn.rb -l 0.0.0.0:8080'
stub_const('::Unicorn', unicorn_type)
stub_const('::Unicorn::HttpServer', unicorn_server_type)
end
it "identifies itself" do
......@@ -73,7 +62,6 @@ describe Gitlab::Runtime do
let(:sidekiq_type) { double('::Sidekiq') }
before do
$0 = '/data/cache/bundle-2.5/bin/sidekiq'
stub_const('::Sidekiq', sidekiq_type)
allow(sidekiq_type).to receive(:server?).and_return(true)
end
......@@ -94,7 +82,6 @@ describe Gitlab::Runtime do
let(:console_type) { double('::Rails::Console') }
before do
$0 = 'bin/rails'
stub_const('::Rails::Console', console_type)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment