From d27224ceca2b1eb0644f593157e398193bd3e2dc Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Wed, 18 Dec 2013 13:49:09 +0100 Subject: [PATCH] Add unicorn-worker-killer with memory check Conflicts: Gemfile.lock --- Gemfile | 1 + Gemfile.lock | 3 +++ config.ru | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/Gemfile b/Gemfile index c3c90dd8c..3eee8d47c 100644 --- a/Gemfile +++ b/Gemfile @@ -86,6 +86,7 @@ gem "asciidoctor" # Application server gem "unicorn", '~> 4.6.3', group: :unicorn +gem 'unicorn-worker-killer', group: :unicorn # State machine gem "state_machine" diff --git a/Gemfile.lock b/Gemfile.lock index 6142d6ef8..8aad7c8c4 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 dfd2d8622..1edcd391e 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 -- 2.11.0