mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #5162 from Matt-Yorkley/unicorn-worker-killer
Add optional unicorn-worker-killer configs
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -118,6 +118,7 @@ gem 'ofn-qz', github: 'openfoodfoundation/ofn-qz', ref: '60da2ae4c44cbb4c8d602f5
|
||||
|
||||
group :production, :staging do
|
||||
gem 'ddtrace'
|
||||
gem 'unicorn-worker-killer'
|
||||
end
|
||||
|
||||
group :test, :development do
|
||||
|
||||
@@ -403,6 +403,8 @@ GEM
|
||||
rspec-core (~> 3.0)
|
||||
ruby-progressbar (~> 1.4)
|
||||
geocoder (1.1.8)
|
||||
get_process_mem (0.2.5)
|
||||
ffi (~> 1.0)
|
||||
gmaps4rails (1.5.6)
|
||||
haml (4.0.7)
|
||||
tilt
|
||||
@@ -660,6 +662,9 @@ GEM
|
||||
unicorn-rails (2.2.1)
|
||||
rack
|
||||
unicorn
|
||||
unicorn-worker-killer (0.4.4)
|
||||
get_process_mem (~> 0)
|
||||
unicorn (>= 4, < 6)
|
||||
uuidtools (2.1.5)
|
||||
warden (1.2.7)
|
||||
rack (>= 1.0)
|
||||
@@ -783,6 +788,7 @@ DEPENDENCIES
|
||||
uglifier (>= 1.0.3)
|
||||
unicorn
|
||||
unicorn-rails
|
||||
unicorn-worker-killer
|
||||
web!
|
||||
webdrivers
|
||||
webmock
|
||||
|
||||
13
config.ru
13
config.ru
@@ -1,4 +1,17 @@
|
||||
# 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', __FILE__)
|
||||
run Openfoodnetwork::Application
|
||||
|
||||
Reference in New Issue
Block a user