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 ...@@ -18,16 +18,16 @@ module Gitlab
end end
def puma? def puma?
!!(defined?(::Puma) && bin == 'puma') !!defined?(::Puma)
end end
# For unicorn, we need to check for actual server instances to avoid false positives. # For unicorn, we need to check for actual server instances to avoid false positives.
def unicorn? def unicorn?
!!(defined?(::Unicorn) && defined?(::Unicorn::HttpServer)) !!defined?(::Unicorn)
end end
def sidekiq? def sidekiq?
!!(defined?(::Sidekiq) && Sidekiq.server? && bin == 'sidekiq') !!Sidekiq.server?
end end
def console? def console?
...@@ -41,22 +41,6 @@ module Gitlab ...@@ -41,22 +41,6 @@ module Gitlab
def multi_threaded? def multi_threaded?
puma? || sidekiq? puma? || sidekiq?
end 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 end
end end
...@@ -3,12 +3,6 @@ ...@@ -3,12 +3,6 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::Runtime do describe Gitlab::Runtime do
REAL_PATH = $0
after(:all) do
$0 = REAL_PATH
end
context "when unknown" do context "when unknown" do
it "identifies as :unknown" do it "identifies as :unknown" do
expect(subject.name).to eq(:unknown) expect(subject.name).to eq(:unknown)
...@@ -17,7 +11,6 @@ describe Gitlab::Runtime do ...@@ -17,7 +11,6 @@ describe Gitlab::Runtime do
context "on multiple matches" do context "on multiple matches" do
before do before do
$0 = '/data/cache/bundle-2.5/bin/puma'
stub_const('::Puma', double) stub_const('::Puma', double)
stub_const('::Rails::Console', double) stub_const('::Rails::Console', double)
end end
...@@ -31,7 +24,6 @@ describe Gitlab::Runtime do ...@@ -31,7 +24,6 @@ describe Gitlab::Runtime do
let(:puma_type) { double('::Puma') } let(:puma_type) { double('::Puma') }
before do before do
$0 = '/data/cache/bundle-2.5/bin/puma'
stub_const('::Puma', puma_type) stub_const('::Puma', puma_type)
end end
...@@ -49,12 +41,9 @@ describe Gitlab::Runtime do ...@@ -49,12 +41,9 @@ describe Gitlab::Runtime do
context "unicorn" do context "unicorn" do
let(:unicorn_type) { Module.new } let(:unicorn_type) { Module.new }
let(:unicorn_server_type) { Class.new }
before do 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', unicorn_type)
stub_const('::Unicorn::HttpServer', unicorn_server_type)
end end
it "identifies itself" do it "identifies itself" do
...@@ -73,7 +62,6 @@ describe Gitlab::Runtime do ...@@ -73,7 +62,6 @@ describe Gitlab::Runtime do
let(:sidekiq_type) { double('::Sidekiq') } let(:sidekiq_type) { double('::Sidekiq') }
before do before do
$0 = '/data/cache/bundle-2.5/bin/sidekiq'
stub_const('::Sidekiq', sidekiq_type) stub_const('::Sidekiq', sidekiq_type)
allow(sidekiq_type).to receive(:server?).and_return(true) allow(sidekiq_type).to receive(:server?).and_return(true)
end end
...@@ -94,7 +82,6 @@ describe Gitlab::Runtime do ...@@ -94,7 +82,6 @@ describe Gitlab::Runtime do
let(:console_type) { double('::Rails::Console') } let(:console_type) { double('::Rails::Console') }
before do before do
$0 = 'bin/rails'
stub_const('::Rails::Console', console_type) stub_const('::Rails::Console', console_type)
end 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