Created
September 20, 2013 15:37
-
-
Save corbanb/6639440 to your computer and use it in GitHub Desktop.
Basic Unicorn and heroku config file.
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
worker_processes Integer(ENV['WEB_CONCURRENCY'] || 4) | |
timeout 120 | |
preload_app true | |
listen ENV['PORT'].to_i || 3000, tcp_nopush: false | |
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 | |
if defined?(ActiveRecord::Base) | |
ActiveRecord::Base.connection.disconnect! | |
Rails.logger.info('Disconnected from ActiveRecord') | |
end | |
if defined?(Resque) | |
Resque.redis.quit | |
end | |
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 | |
if defined?(ActiveRecord::Base) | |
ActiveRecord::Base.establish_connection | |
Rails.logger.info('Connected to ActiveRecord') | |
end | |
# Reset the object cache store (Dalli) | |
if Rails.cache.respond_to?(:reset) | |
Rails.cache.reset | |
Rails.logger.info('Rails cache has been reset') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment