Skip to content

Instantly share code, notes, and snippets.

@blaz
Created July 17, 2014 10:03
Show Gist options
  • Select an option

  • Save blaz/39d14fce9ee63c20838c to your computer and use it in GitHub Desktop.

Select an option

Save blaz/39d14fce9ee63c20838c to your computer and use it in GitHub Desktop.
unicorn.rb heroku oobgc killer config
require './lib/configuration/active_record'
require './lib/configuration/processors'
worker_processes Integer(ENV["UNICORN_WORKERS"] || ::Configuration::Processors.count)
timeout 25
preload_app true
before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
end
::Configuration::ActiveRecord.disconnect
end
after_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
end
::Configuration::ActiveRecord.connect
end
listen ENV['PORT'], backlog: Integer(ENV['UNICORN_BACKLOG'] || 15)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment