diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2018-07-20 15:50:41 +0200 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2018-07-20 15:50:41 +0200 |
commit | b7afdfce2786cdd2cd1389eabf84fb90a22b60ce (patch) | |
tree | fab22d1c7817e6992ff3fc58a17036ae4c8b72ed | |
parent | 3565786372ab959082ace33e2aa409c7554364fa (diff) | |
download | gitlab-ce-b7afdfce2786cdd2cd1389eabf84fb90a22b60ce.tar.gz |
Update Puma version and config
-rw-r--r-- | Gemfile | 2 | ||||
-rw-r--r-- | Gemfile.lock | 4 | ||||
-rw-r--r-- | config/initializers/puma.rb | 22 | ||||
-rw-r--r-- | config/puma.rb.example | 28 |
4 files changed, 31 insertions, 25 deletions
@@ -162,7 +162,7 @@ group :unicorn do end group :puma do - gem 'puma', '~> 2.15', require: false + gem 'puma', '~> 3.12', require: false gem 'puma_worker_killer', require: false end diff --git a/Gemfile.lock b/Gemfile.lock index 846c8f7b399..e4d6764dd56 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -641,7 +641,7 @@ GEM pry-rails (0.3.5) pry (>= 0.9.10) public_suffix (3.0.2) - puma (2.16.0) + puma (3.12.0) puma_worker_killer (0.1.0) get_process_mem (~> 0.2) puma (>= 2.7, < 4) @@ -1121,7 +1121,7 @@ DEPENDENCIES prometheus-client-mmap (~> 0.9.3) pry-byebug (~> 3.4.1) pry-rails (~> 0.3.4) - puma (~> 2.15) + puma (~> 3.12) puma_worker_killer rack-attack (~> 4.4.1) rack-cors (~> 1.0.0) diff --git a/config/initializers/puma.rb b/config/initializers/puma.rb deleted file mode 100644 index f737f07f1fe..00000000000 --- a/config/initializers/puma.rb +++ /dev/null @@ -1,22 +0,0 @@ -if ENV['USE_PUMA'] - require 'puma' - require 'puma_worker_killer' - - if Rails.env.production? or Rails.env.staging? - PumaWorkerKiller.config do |config| - config.ram = 250 - config.frequency = 5 - - # We just wan't to limit to a fixed maximum, unrelated to the total amount - # of available RAM. - config.percent_usage = 100.0 - - # Ideally we'll never hit the maximum amount of memory. If so the worker - # is restarted already, thus periodically restarting workers shouldn't be - # needed. - config.rolling_restart_frequency = false - end - - PumaWorkerKiller.start - end -end diff --git a/config/puma.rb.example b/config/puma.rb.example index 27ec98b5d37..470801140fd 100644 --- a/config/puma.rb.example +++ b/config/puma.rb.example @@ -111,8 +111,36 @@ workers 3 # puts 'On worker boot...' # end +before_fork do + if Rails.env.production? or Rails.env.staging? + require 'puma_worker_killer' + + PumaWorkerKiller.config do |config| + # For now we use the same environment variable as Unicorn, making it + # easier to replace Unicorn with Puma. + config.ram = (ENV['GITLAB_UNICORN_MEMORY_MAX'] || 650 * 1 << 20).to_i + + config.frequency = 5 + + # We just wan't to limit to a fixed maximum, unrelated to the total amount + # of available RAM. + config.percent_usage = 100.0 + + # Ideally we'll never hit the maximum amount of memory. If so the worker + # is restarted already, thus periodically restarting workers shouldn't be + # needed. + config.rolling_restart_frequency = false + end + + PumaWorkerKiller.start + end +end + on_worker_boot do ActiveRecord::Base.establish_connection if defined?(ActiveRecord::Base) + + defined?(::Prometheus::Client.reinitialize_on_pid_change) && + Prometheus::Client.reinitialize_on_pid_change end # Code to run when a worker boots to setup the process after booting |