From 4fe49fe5591c5ba21de8065983f46d0b1b4023d1 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 5 Jun 2021 11:13:25 +0100 Subject: [PATCH] Switch from Unicorn to Puma --- Gemfile | 4 ++-- Gemfile.lock | 20 +++++--------------- config.ru | 13 ------------- 3 files changed, 7 insertions(+), 30 deletions(-) diff --git a/Gemfile b/Gemfile index 126b63a797..f73f8a7780 100644 --- a/Gemfile +++ b/Gemfile @@ -83,6 +83,7 @@ gem 'rack-rewrite' gem 'rack-ssl', require: 'rack/ssl' gem 'roadie-rails' +gem 'puma' gem 'hiredis' gem 'redis', '>= 4.0', require: ['redis', 'redis/connection/hiredis'] gem 'sidekiq' @@ -128,7 +129,7 @@ gem "view_component", require: "view_component/engine" group :production, :staging do gem 'ddtrace' - gem 'unicorn-worker-killer' + gem 'sd_notify' # For better Systemd process management. Used by Puma. end group :test, :development do @@ -148,7 +149,6 @@ group :test, :development do gem 'selenium-webdriver' gem 'shoulda-matchers' gem 'timecop' - gem 'unicorn-rails' gem 'webdrivers' gem 'cuprite' end diff --git a/Gemfile.lock b/Gemfile.lock index 784ad40705..5c5fd23259 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -319,8 +319,6 @@ GEM rspec-core (~> 3.0) ruby-progressbar (~> 1.4) geocoder (1.6.7) - get_process_mem (0.2.7) - ffi (~> 1.0) globalid (0.4.2) activesupport (>= 4.2.0) gmaps4rails (2.1.2) @@ -355,7 +353,6 @@ GEM multi_json (~> 1.0) rspec (>= 2.0, < 4.0) jwt (2.2.3) - kgio (2.11.3) knapsack (3.1.0) rake launchy (2.5.0) @@ -435,6 +432,8 @@ GEM byebug (~> 11.0) pry (~> 0.13.0) public_suffix (4.0.6) + puma (5.3.2) + nio4r (~> 2.0) raabro (1.4.0) racc (1.5.2) rack (2.2.3) @@ -484,7 +483,6 @@ GEM rake (>= 0.13) thor (~> 1.0) rainbow (3.0.0) - raindrops (0.19.1) rake (13.0.3) ransack (2.4.2) activerecord (>= 5.2.4) @@ -575,6 +573,7 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) + sd_notify (0.1.1) selenium-webdriver (3.142.7) childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) @@ -632,15 +631,6 @@ GEM uglifier (4.2.0) execjs (>= 0.3.0, < 3) unicode-display_width (2.0.0) - unicorn (6.0.0) - kgio (~> 2.6) - raindrops (~> 0.7) - unicorn-rails (2.2.1) - rack - unicorn - unicorn-worker-killer (0.4.5) - get_process_mem (~> 0) - unicorn (>= 4, < 7) uniform_notifier (1.14.2) valid_email2 (4.0.0) activemodel (>= 3.2) @@ -769,6 +759,7 @@ DEPENDENCIES pg (~> 1.2.3) pry (~> 0.13.0) pry-byebug (~> 3.9.0) + puma rack-mini-profiler (< 3.0.0) rack-rewrite rack-ssl @@ -788,6 +779,7 @@ DEPENDENCIES rubocop rubocop-rails sass-rails (< 5.1.0) + sd_notify select2-rails! selenium-webdriver shoulda-matchers @@ -803,8 +795,6 @@ DEPENDENCIES test-unit (~> 3.4) timecop uglifier (>= 1.0.3) - unicorn-rails - unicorn-worker-killer valid_email2 view_component view_component_storybook diff --git a/config.ru b/config.ru index 0e1070856d..b834259514 100644 --- a/config.ru +++ b/config.ru @@ -2,18 +2,5 @@ # This file is used by Rack-based servers to start the application. -if ENV.fetch('KILL_UNICORNS', false) && ['production', 'staging'].include?(ENV['RAILS_ENV']) - # Gracefully restart individual unicorn workers if they have: - # - performed between 25000 and 30000 requests - # - grown in memory usage to between 700 and 850 MB - require 'unicorn/worker_killer' - use Unicorn::WorkerKiller::MaxRequests, - ENV.fetch('UWK_REQS_MIN', 25_000).to_i, - ENV.fetch('UWK_REQS_MAX', 30_000).to_i - use Unicorn::WorkerKiller::Oom, - ( ENV.fetch('UWK_MEM_MIN', 700).to_i * (1024**2) ), - ( ENV.fetch('UWK_MEM_MAX', 850).to_i * (1024**2) ) -end - require ::File.expand_path('config/environment', __dir__) run Openfoodnetwork::Application