main
 1worker_processes 8
 2timeout 15
 3preload_app true
 4
 5before_fork do |server, worker|
 6  Signal.trap 'TERM' do
 7    puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
 8    Process.kill 'QUIT', Process.pid
 9  end
10
11  if defined?(ActiveRecord::Base)
12    ActiveRecord::Base.connection.disconnect!
13    Rails.logger.info('Disconnected from ActiveRecord')
14  end
15end
16
17after_fork do |server, worker|
18  Signal.trap 'TERM' do
19    puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT'
20  end
21
22  if defined?(ActiveRecord::Base)
23    ActiveRecord::Base.establish_connection
24    Rails.logger.info('Connected to ActiveRecord')
25  end
26end