diff --git a/Gemfile b/Gemfile index c3c90dd8c053b24ed18ba63e5268a75d531b8b3e..2019cae8f96ffc1ad330e4a3f738e0434427b91b 100644 --- a/Gemfile +++ b/Gemfile @@ -85,7 +85,10 @@ gem "github-markup", "~> 0.7.4", require: 'github/markup' gem "asciidoctor" # Application server -gem "unicorn", '~> 4.6.3', group: :unicorn +group :unicorn do + gem "unicorn", '~> 4.6.3' + gem 'unicorn-worker-killer' +end # State machine gem "state_machine" diff --git a/Gemfile.lock b/Gemfile.lock index 6142d6ef8cf3edf32bcec9bf2127e8d68b95addd..8aad7c8c424e71ebf890e867bc13e488d094515b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -539,6 +539,8 @@ GEM kgio (~> 2.6) rack raindrops (~> 0.7) + unicorn-worker-killer (0.4.2) + unicorn (~> 4) virtus (1.0.1) axiom-types (~> 0.0.5) coercible (~> 1.0) @@ -660,4 +662,5 @@ DEPENDENCIES uglifier underscore-rails (~> 1.4.4) unicorn (~> 4.6.3) + unicorn-worker-killer webmock diff --git a/config.ru b/config.ru index dfd2d862237323aa599be31b473d70a8a817943b..1edcd391e45698a277440361fce6b1c3a013837c 100644 --- a/config.ru +++ b/config.ru @@ -1,5 +1,11 @@ # This file is used by Rack-based servers to start the application. +# Unicorn self-process killer +require 'unicorn/worker_killer' + +# # Max memory size (RSS) per worker +use Unicorn::WorkerKiller::Oom, (200 * (1 << 20)), (250 * (1 << 20)) + require ::File.expand_path('../config/environment', __FILE__) map ENV['RAILS_RELATIVE_URL_ROOT'] || "/" do