fix unicorn.rb

This commit is contained in:
Tyrel Souza 2014-04-29 14:08:19 -04:00
parent 1e42735a00
commit e36b84e7d3

View File

@ -1,7 +1,5 @@
# https://devcenter.heroku.com/articles/rails-unicorn worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
timeout 15
worker_processes (ENV['WEB_CONCURRENCY'] || 3).to_i
timeout (ENV['WEB_TIMEOUT'] || 5).to_i
preload_app true preload_app true
before_fork do |server, worker| before_fork do |server, worker|
@ -10,20 +8,15 @@ before_fork do |server, worker|
Process.kill 'QUIT', Process.pid Process.kill 'QUIT', Process.pid
end end
if defined? ActiveRecord::Base defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect! ActiveRecord::Base.connection.disconnect!
end
end end
after_fork do |server, worker| after_fork do |server, worker|
Signal.trap 'TERM' do Signal.trap 'TERM' do
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT' puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
end end
if defined? ActiveRecord::Base defined?(ActiveRecord::Base) and
config = Rails.application.config.database_configuration[Rails.env] ActiveRecord::Base.establish_connection
config['reaping_frequency'] = (ENV['DB_REAPING_FREQUENCY'] || 10).to_i
config['pool'] = (ENV['DB_POOL'] || 2).to_i
ActiveRecord::Base.establish_connection(config)
end
end end