Skip to content

Instantly share code, notes, and snippets.

@thilo
Created October 9, 2013 19:30
Show Gist options
  • Save thilo/6906882 to your computer and use it in GitHub Desktop.
Save thilo/6906882 to your computer and use it in GitHub Desktop.
A default unicorn config for a Rack app (not Rails) on Heroku
worker_processes 3
timeout 10
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
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.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
defined?(ActiveRecord::Base) and
config = ActiveRecord::Base.configurations[ENV['RACK_ENV'].to_sym]
ActiveRecord::Base.establish_connection(config)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment