Created
August 27, 2014 13:14
-
-
Save localhots/e168239f97ff757487a5 to your computer and use it in GitHub Desktop.
Unicorn worker killer + out-of-band garbage collection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bundler' | |
Bundler.setup | |
require 'unicorn' | |
begin | |
# Unicorn self-process killer | |
require 'unicorn/worker_killer' | |
# Max requests per worker | |
use Unicorn::WorkerKiller::MaxRequests, 1000, 1500 | |
# Max memory size (RSS) per worker | |
mb = 1024**2 | |
use Unicorn::WorkerKiller::Oom, 400*mb, 500*mb | |
# Run garbage collection between requests | |
require 'unicorn/oob_gc' | |
GC.disable | |
use Unicorn::OobGC, 30 # each 30 requests | |
rescue LoadError | |
end | |
require ::File.expand_path('../config/environment', __FILE__) | |
run Rails.application |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment