Skip to content

Commit

Permalink
Add unicorn config.
Browse files Browse the repository at this point in the history
  • Loading branch information
studiospring committed Sep 23, 2015
1 parent 9807ba6 commit ccb3583
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions config/unicorn.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
if ENV["RAILS_ENV"] == "development"
worker_processes 1
else
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
end

timeout 15
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) &&
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) &&
ActiveRecord::Base.establish_connection
end

0 comments on commit ccb3583

Please sign in to comment.