Skip to content

Commit 1934927

Browse files
kkimuraksachilles
authored andcommitted
sync config/gitlabhq/puma.rb to gitlab v18.7.0
Without those changes puma (and then gitlab itself) does not starts See following upstream changes: - https://gitlab.com/gitlab-org/gitlab/-/merge_requests/128619 (overwritten by gitlab-org/gitlab!132581) - https://gitlab.com/gitlab-org/gitlab/-/merge_requests/132581 - https://gitlab.com/gitlab-org/gitlab/-/merge_requests/211331
1 parent baa49e0 commit 1934927

File tree

1 file changed

+39
-23
lines changed
  • assets/runtime/config/gitlabhq

1 file changed

+39
-23
lines changed

assets/runtime/config/gitlabhq/puma.rb

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,45 @@
4040

4141
require_relative "{{GITLAB_INSTALL_DIR}}/lib/gitlab/cluster/lifecycle_events"
4242

43-
on_restart do
44-
# Signal application hooks that we're about to restart
45-
Gitlab::Cluster::LifecycleEvents.do_before_master_restart
46-
end
43+
if Gem::Version.new(Puma::Const::PUMA_VERSION) < Gem::Version.new('7.0')
44+
Gitlab::Cluster::LifecycleEvents.set_puma_options @config.options
4745

48-
before_fork do
49-
# Signal to the puma killer
50-
Gitlab::Cluster::PumaWorkerKillerInitializer.start(@config.options, puma_per_worker_max_memory_mb: {{PUMA_PER_WORKER_MAX_MEMORY_MB}}, puma_master_max_memory_mb: {{PUMA_MASTER_MAX_MEMORY_MB}}) unless ENV['DISABLE_PUMA_WORKER_KILLER']
46+
on_restart do
47+
# Signal application hooks that we're about to restart
48+
Gitlab::Cluster::LifecycleEvents.do_before_master_restart
49+
end
5150

52-
# Signal application hooks that we're about to fork
53-
Gitlab::Cluster::LifecycleEvents.do_before_fork
54-
end
51+
on_worker_boot do
52+
# Signal application hooks of worker start
53+
Gitlab::Cluster::LifecycleEvents.do_worker_start
54+
end
5555

56-
Gitlab::Cluster::LifecycleEvents.set_puma_options @config.options
57-
on_worker_boot do
58-
# Signal application hooks of worker start
59-
Gitlab::Cluster::LifecycleEvents.do_worker_start
56+
on_worker_shutdown do
57+
# Signal application hooks that a worker is shutting down
58+
Gitlab::Cluster::LifecycleEvents.do_worker_stop
59+
end
60+
else
61+
Gitlab::Cluster::LifecycleEvents.set_puma_worker_count(3)
62+
63+
before_restart do
64+
# Signal application hooks that we're about to restart
65+
Gitlab::Cluster::LifecycleEvents.do_before_master_restart
66+
end
67+
68+
before_worker_boot do
69+
# Signal application hooks of worker start
70+
Gitlab::Cluster::LifecycleEvents.do_worker_start
71+
end
72+
73+
before_worker_shutdown do
74+
# Signal application hooks that a worker is shutting down
75+
Gitlab::Cluster::LifecycleEvents.do_worker_stop
76+
end
6077
end
6178

62-
on_worker_shutdown do
63-
# Signal application hooks that a worker is shutting down
64-
Gitlab::Cluster::LifecycleEvents.do_worker_stop
79+
before_fork do
80+
# Signal application hooks that we're about to fork
81+
Gitlab::Cluster::LifecycleEvents.do_before_fork
6582
end
6683

6784
# Preload the application before starting the workers; this conflicts with
@@ -87,11 +104,10 @@
87104
json_formatter.call(str)
88105
end
89106

90-
lowlevel_error_handler do |ex, env|
91-
if Raven.configuration.capture_allowed?
92-
Raven.capture_exception(ex, tags: { 'handler': 'puma_low_level' }, extra: { puma_env: env })
93-
end
107+
require_relative "{{GITLAB_INSTALL_DIR}}/lib/gitlab/puma/error_handler"
108+
109+
error_handler = Gitlab::Puma::ErrorHandler.new(ENV['RAILS_ENV'] == 'production')
94110

95-
# note the below is just a Rack response
96-
[500, {}, ["An error has occurred and reported in the system's low-level error handler."]]
111+
lowlevel_error_handler do |ex, env, status_code|
112+
error_handler.execute(ex, env, status_code)
97113
end

0 commit comments

Comments
 (0)