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>2022-12-20 17:22:11 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-12-20 17:22:11 +0300
commit0c872e02b2c822e3397515ec324051ff540f0cd5 (patch)
treece2fb6ce7030e4dad0f4118d21ab6453e5938cdd /sidekiq_cluster
parentf7e05a6853b12f02911494c4b3fe53d9540d74fc (diff)
Add latest changes from gitlab-org/gitlab@15-7-stable-eev15.7.0-rc42
Diffstat (limited to 'sidekiq_cluster')
-rw-r--r--sidekiq_cluster/cli.rb15
-rw-r--r--sidekiq_cluster/sidekiq_cluster.rb10
2 files changed, 17 insertions, 8 deletions
diff --git a/sidekiq_cluster/cli.rb b/sidekiq_cluster/cli.rb
index 52dc14130fb..760a5f14c2d 100644
--- a/sidekiq_cluster/cli.rb
+++ b/sidekiq_cluster/cli.rb
@@ -31,8 +31,9 @@ module Gitlab
CommandError = Class.new(StandardError)
def initialize(log_output = $stderr)
- # As recommended by https://github.com/mperham/sidekiq/wiki/Advanced-Options#concurrency
- @max_concurrency = 50
+ # https://github.com/mperham/sidekiq/wiki/Advanced-Options#concurrency
+ # https://ruby.social/@getajobmike/109326475545816363
+ @max_concurrency = 20
@min_concurrency = 0
@environment = ENV['RAILS_ENV'] || 'development'
@metrics_dir = ENV["prometheus_multiproc_dir"] || File.absolute_path("tmp/prometheus_multiproc_dir/sidekiq")
@@ -111,7 +112,7 @@ module Gitlab
end
def start_and_supervise_workers(queue_groups)
- worker_pids = SidekiqCluster.start(
+ wait_threads = SidekiqCluster.start(
queue_groups,
env: @environment,
directory: @rails_path,
@@ -134,6 +135,7 @@ module Gitlab
)
metrics_server_pid = start_metrics_server
+ worker_pids = wait_threads.map(&:pid)
supervisor.supervise(worker_pids + Array(metrics_server_pid)) do |dead_pids|
# If we're not in the process of shutting down the cluster,
# and the metrics server died, restart it.
@@ -148,6 +150,13 @@ module Gitlab
[]
end
end
+
+ exit_statuses = wait_threads.map do |thread|
+ thread.join
+ thread.value
+ end
+
+ exit 1 unless exit_statuses.compact.all?(&:success?)
end
def start_metrics_server
diff --git a/sidekiq_cluster/sidekiq_cluster.rb b/sidekiq_cluster/sidekiq_cluster.rb
index c68cbe7c163..1ed08e7e839 100644
--- a/sidekiq_cluster/sidekiq_cluster.rb
+++ b/sidekiq_cluster/sidekiq_cluster.rb
@@ -1,6 +1,7 @@
# frozen_string_literal: true
require_relative '../lib/gitlab/process_management'
+require_relative '../lib/gitlab/process_supervisor'
module Gitlab
module SidekiqCluster
@@ -33,8 +34,9 @@ module Gitlab
#
# directory - The directory of the Rails application.
#
- # Returns an Array containing the PIDs of the started processes.
- def self.start(queues, env: :development, directory: Dir.pwd, max_concurrency: 50, min_concurrency: 0, timeout: DEFAULT_SOFT_TIMEOUT_SECONDS, dryrun: false)
+ # Returns an Array containing the waiter threads (from Process.detach) of
+ # the started processes.
+ def self.start(queues, env: :development, directory: Dir.pwd, max_concurrency: 20, min_concurrency: 0, timeout: DEFAULT_SOFT_TIMEOUT_SECONDS, dryrun: false)
queues.map.with_index do |pair, index|
start_sidekiq(pair, env: env,
directory: directory,
@@ -82,9 +84,7 @@ module Gitlab
)
end
- ProcessManagement.wait_async(pid)
-
- pid
+ Process.detach(pid)
end
def self.count_by_queue(queues)