summaryrefslogtreecommitdiff
path: root/sidekiq_cluster
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-05-19 07:33:21 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-05-19 07:33:21 +0000
commit36a59d088eca61b834191dacea009677a96c052f (patch)
treee4f33972dab5d8ef79e3944a9f403035fceea43f /sidekiq_cluster
parenta1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff)
downloadgitlab-ce-36a59d088eca61b834191dacea009677a96c052f.tar.gz
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'sidekiq_cluster')
-rw-r--r--sidekiq_cluster/cli.rb33
1 files changed, 6 insertions, 27 deletions
diff --git a/sidekiq_cluster/cli.rb b/sidekiq_cluster/cli.rb
index c0940370d3b..52dc14130fb 100644
--- a/sidekiq_cluster/cli.rb
+++ b/sidekiq_cluster/cli.rb
@@ -20,7 +20,7 @@ require_relative 'sidekiq_cluster'
module Gitlab
module SidekiqCluster
class CLI
- THREAD_NAME = 'supervisor'
+ THREAD_NAME = 'sidekiq-cluster'
# The signals that should terminate both the master and workers.
TERMINATE_SIGNALS = %i(INT TERM).freeze
@@ -134,23 +134,17 @@ module Gitlab
)
metrics_server_pid = start_metrics_server
-
- all_pids = worker_pids + Array(metrics_server_pid)
-
- supervisor.supervise(all_pids) do |dead_pids|
+ 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.
- if supervisor.alive && dead_pids.include?(metrics_server_pid)
+ if dead_pids == Array(metrics_server_pid)
@logger.info('Sidekiq metrics server terminated, restarting...')
metrics_server_pid = restart_metrics_server
- all_pids = worker_pids + Array(metrics_server_pid)
else
# If a worker process died we'll just terminate the whole cluster.
# We let an external system (runit, kubernetes) handle the restart.
@logger.info('A worker terminated, shutting down the cluster')
-
- ProcessManagement.signal_processes(all_pids - dead_pids, :TERM)
- # Signal supervisor not to respawn workers and shut down.
+ supervisor.shutdown
[]
end
end
@@ -164,8 +158,7 @@ module Gitlab
def restart_metrics_server
@logger.info("Starting metrics server on port #{sidekiq_exporter_port}")
- MetricsServer.fork(
- 'sidekiq',
+ MetricsServer.start_for_sidekiq(
metrics_dir: @metrics_dir,
reset_signals: TERMINATE_SIGNALS + FORWARD_SIGNALS
)
@@ -175,26 +168,12 @@ module Gitlab
::Settings.dig('monitoring', 'sidekiq_exporter', 'enabled')
end
- def exporter_has_a_unique_port?
- # In https://gitlab.com/gitlab-org/gitlab/-/issues/345802 we added settings for sidekiq_health_checks.
- # These settings default to the same values as sidekiq_exporter for backwards compatibility.
- # If a different port for sidekiq_health_checks has been set up, we know that the
- # user wants to serve health checks and metrics from different servers.
- return false if sidekiq_health_check_port.nil? || sidekiq_exporter_port.nil?
-
- sidekiq_exporter_port != sidekiq_health_check_port
- end
-
def sidekiq_exporter_port
::Settings.dig('monitoring', 'sidekiq_exporter', 'port')
end
- def sidekiq_health_check_port
- ::Settings.dig('monitoring', 'sidekiq_health_checks', 'port')
- end
-
def metrics_server_enabled?
- !@dryrun && sidekiq_exporter_enabled? && exporter_has_a_unique_port?
+ !@dryrun && sidekiq_exporter_enabled?
end
def option_parser