Created
March 23, 2016 18:17
-
-
Save armiller/23d79a19ea3f40c28004 to your computer and use it in GitHub Desktop.
Example unicorn configuration file
This file contains hidden or 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
# set path to application | |
app_dir = File.expand_path("../..", __FILE__) | |
shared_dir = "#{app_dir}/shared" | |
working_directory app_dir | |
# Set unicorn options | |
worker_processes 2 | |
preload_app true | |
timeout 30 | |
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) and | |
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) and | |
ActiveRecord::Base.establish_connection | |
end | |
# Logging | |
stderr_path "#{shared_dir}/log/unicorn.stderr.log" | |
stdout_path "#{shared_dir}/log/unicorn.stdout.log" | |
# Set master PID location | |
pid "#{shared_dir}/pids/unicorn.pid" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment