Created
June 23, 2013 23:24
-
-
Save hschoenburg/5846911 to your computer and use it in GitHub Desktop.
unicorn.rb
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
# config/unicorn.rb | |
# See comment by @paulelliott | |
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3) | |
timeout 29 | |
preload_app true | |
# Shouldn't need to do anything for redis, since it's already connecting-on-request rather than on boot. | |
before_fork do |server, worker| | |
if defined?(ActiveRecord::Base) | |
ActiveRecord::Base.connection.disconnect! | |
end | |
Signal.trap 'TERM' do | |
puts 'Unicorn master intercepting TERM and sending myself QUIT instead' | |
Process.kill 'QUIT', Process.pid | |
end | |
end | |
after_fork do |server, worker| | |
defined?(ActiveRecord::Base) && ActiveRecord::Base.establish_connection | |
# , max_queue_size: 2, on_error: Proc.new { |status, msg| Rails.logger.fatal "analytics: #{msg}" }, batch_size: 1 | |
# defined?(Analytics) && ENV['SEGMENT_IO_SECRET'] && Analytics.init(secret: ENV['SEGMENT_IO_SECRET']) if Feature.metrics? | |
Signal.trap 'TERM' do | |
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment