diff options
author | Andrew Newdigate <andrew@gitlab.com> | 2019-06-13 11:36:55 +0200 |
---|---|---|
committer | Andrew Newdigate <andrew@gitlab.com> | 2019-06-13 13:16:08 +0200 |
commit | 075d62bfd9e795f458749d2e9f32f1dba964d971 (patch) | |
tree | ca7bb3782aeb836200d913c6bd9047ca4e26244f | |
parent | 10ea97505f134ec4b43c93071a02d1498f2e5fc3 (diff) | |
download | gitlab-ce-an-move-puma-killer-to-an-initializer.tar.gz |
Attach the Puma Worker Killer through Lifecycle Eventsan-move-puma-killer-to-an-initializer
This approach is the new favoured way of attaching lifecycle events, as
it does not require additional changes to be made to the puma.rb file
in GitLab-CE, Omnibus and Cloud Native GitLab. If these changes are not
synchronized, they may fail in certain environments.
Moving to lifecycle events avoids having to do this.
Additionally, this change will only install the puma-worker-killer
when Puma is running in multi-process mode. Puma can also run in single
process mode. In this mode, the puma-worker-killer would be ineffective.
-rw-r--r-- | changelogs/unreleased/an-move-puma-killer-to-an-initializer.yml | 5 | ||||
-rw-r--r-- | config/initializers/puma.rb | 11 | ||||
-rw-r--r-- | config/puma.example.development.rb | 3 | ||||
-rw-r--r-- | config/puma.rb.example | 4 | ||||
-rw-r--r-- | lib/gitlab/cluster/lifecycle_events.rb | 2 |
5 files changed, 16 insertions, 9 deletions
diff --git a/changelogs/unreleased/an-move-puma-killer-to-an-initializer.yml b/changelogs/unreleased/an-move-puma-killer-to-an-initializer.yml new file mode 100644 index 00000000000..5a38bb2e339 --- /dev/null +++ b/changelogs/unreleased/an-move-puma-killer-to-an-initializer.yml @@ -0,0 +1,5 @@ +--- +title: Attach the Puma Worker Killer through Lifecycle Events +merge_request: 29594 +author: +type: other diff --git a/config/initializers/puma.rb b/config/initializers/puma.rb new file mode 100644 index 00000000000..bf56be41b9b --- /dev/null +++ b/config/initializers/puma.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +require "gitlab/cluster/lifecycle_events" + +if Gitlab::Cluster::LifecycleEvents.in_clustered_puma? + unless ENV['DISABLE_PUMA_WORKER_KILLER'] + require "gitlab/cluster/puma_worker_killer_initializer" + + Gitlab::Cluster::PumaWorkerKillerInitializer.start @config.options unless ENV['DISABLE_PUMA_WORKER_KILLER'] + end +end diff --git a/config/puma.example.development.rb b/config/puma.example.development.rb index 9df24bf74e3..061825d866e 100644 --- a/config/puma.example.development.rb +++ b/config/puma.example.development.rb @@ -49,9 +49,6 @@ on_restart do end before_fork do - # Signal to the puma killer - Gitlab::Cluster::PumaWorkerKillerInitializer.start @config.options unless ENV['DISABLE_PUMA_WORKER_KILLER'] - # Signal application hooks that we're about to fork Gitlab::Cluster::LifecycleEvents.do_before_fork end diff --git a/config/puma.rb.example b/config/puma.rb.example index 6558dbc6cfe..4d1dcef30b6 100644 --- a/config/puma.rb.example +++ b/config/puma.rb.example @@ -36,7 +36,6 @@ bind 'unix:///home/git/gitlab/tmp/sockets/gitlab.socket' workers 3 require_relative "/home/git/gitlab/lib/gitlab/cluster/lifecycle_events" -require_relative "/home/git/gitlab/lib/gitlab/cluster/puma_worker_killer_initializer" on_restart do # Signal application hooks that we're about to restart @@ -44,9 +43,6 @@ on_restart do end before_fork do - # Signal to the puma killer - Gitlab::Cluster::PumaWorkerKillerInitializer.start @config.options unless ENV['DISABLE_PUMA_WORKER_KILLER'] - # Signal application hooks that we're about to fork Gitlab::Cluster::LifecycleEvents.do_before_fork end diff --git a/lib/gitlab/cluster/lifecycle_events.rb b/lib/gitlab/cluster/lifecycle_events.rb index e0f9eb59924..1bd3bb942c7 100644 --- a/lib/gitlab/cluster/lifecycle_events.rb +++ b/lib/gitlab/cluster/lifecycle_events.rb @@ -80,8 +80,6 @@ module Gitlab @puma_options = options end - private - def in_clustered_environment? # Sidekiq doesn't fork return false if Sidekiq.server? |