Commit 4d0dce5d authored by Stan Hu's avatar Stan Hu

Merge branch 'ce-40396-sidekiq-cluster-pgroups' into 'master'

sidekiq-cluster: put each sidekiq in a new pgroup

See merge request gitlab-org/gitlab-ee!9775
parents fdb6105e 59e19c49
---
title: 'sidekiq-cluster: put each sidekiq in a new pgroup'
merge_request: 9775
author:
type: other
......@@ -56,7 +56,7 @@ module Gitlab
# start([ ['foo'], ['bar', 'baz'] ], :production)
#
# This would start two Sidekiq processes: one processing "foo", and one
# processing "bar" and "baz".
# processing "bar" and "baz". Each one is placed in its own process group.
#
# queues - An Array containing Arrays. Each sub Array should specify the
# queues to use for a single process.
......@@ -92,6 +92,7 @@ module Gitlab
pid = Process.spawn(
{ 'ENABLE_SIDEKIQ_CLUSTER' => '1' },
*cmd,
pgroup: true,
err: $stderr,
out: $stdout
)
......
......@@ -79,6 +79,7 @@ describe Gitlab::SidekiqCluster do
describe '.start_sidekiq' do
let(:env) { { "ENABLE_SIDEKIQ_CLUSTER" => "1" } }
let(:args) { ['bundle', 'exec', 'sidekiq', anything, '-eproduction', *([anything] * 5)] }
it 'starts a Sidekiq process' do
allow(Process).to receive(:spawn).and_return(1)
......@@ -88,13 +89,24 @@ describe Gitlab::SidekiqCluster do
end
it 'handles duplicate queue names' do
allow(Process).to receive(:spawn)
.with(env, "bundle", "exec", "sidekiq", "-c 5", "-eproduction", "-gqueues: foo (2), bar, baz", anything, "-qfoo,2", "-qbar,1", "-qbaz,1", anything)
.and_return(1)
allow(Process)
.to receive(:spawn)
.with(env, *args, anything)
.and_return(1)
expect(described_class).to receive(:wait_async).with(1)
expect(described_class.start_sidekiq(%w(foo foo bar baz), :production)).to eq(1)
end
it 'runs the sidekiq process in a new process group' do
expect(Process)
.to receive(:spawn)
.with(anything, *args, a_hash_including(pgroup: true))
.and_return(1)
allow(described_class).to receive(:wait_async)
expect(described_class.start_sidekiq(%w(foo bar baz), :production)).to eq(1)
end
end
describe '.wait_async' do
......
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