Skip to content

Commit

Permalink
Merge pull request #34 from airbnb/jimmy_ngo--worker_killer
Browse files Browse the repository at this point in the history
[enhancement] Add unicorn-worker-killer to recycle unicorn workers
  • Loading branch information
jimmyngo authored Jul 19, 2017
2 parents b1203aa + a5bb973 commit 7d24bd5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
source 'https://rubygems.org'

gem 'sinatra', '~> 1.4.4'
gem 'zk', '~> 1.9.3'
gem 'unicorn', '~> 4.8.3'
gem 'hash-deep-merge', '~> 0.1.1'
gem 'newrelic_rpm', '~> 3.18.1', group: :newrelic
gem 'stomp', '~> 1.3.2'
gem 'statsd-ruby', '~> 1.2.1'
gem 'sinatra', '~> 1.4.4'
gem 'zk', '~> 1.9.3'
gem 'unicorn', '~> 4.8.3'
gem 'unicorn-worker-killer', '~> 0.4.4'
gem 'hash-deep-merge', '~> 0.1.1'
gem 'newrelic_rpm', '~> 3.18.1', group: :newrelic
gem 'stomp', '~> 1.3.2'
gem 'statsd-ruby', '~> 1.2.1'
19 changes: 19 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@ STATSD = Statsd.new(opts['statsd_host'], opts['statsd_port'])
# prepare to exit cleanly
$EXIT = false

# configure unicorn-worker-killer
if opts['worker_killer']
require 'unicorn/worker_killer'

wk_opts = opts['worker_killer']

if wk_opts['max_requests']
max_requests = wk_opts['max_requests']
# Max requests per worker
use Unicorn::WorkerKiller::MaxRequests, max_requests['min'], max_requests['max']
end

if wk_opts['mem_limit']
mem_limit = wk_opts['mem_limit']
# Max memory size (RSS) per worker
use Unicorn::WorkerKiller::Oom, mem_limit['min'], mem_limit['max']
end
end

# configure the store
require './store.rb'
store = Store.new(opts)
Expand Down

0 comments on commit 7d24bd5

Please sign in to comment.