Created
August 22, 2014 19:12
-
-
Save pablitoc/22a56736931c548f2667 to your computer and use it in GitHub Desktop.
Unicorn Config
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
require 'dotenv' | |
worker_processes Integer(ENV['WEB_CONCURRENCY'] || 3) | |
timeout 15 | |
preload_app true | |
stderr_path "/srv/#{application}/shared/log/"ENV['RAILS_ENV']".log" | |
stdout_path "/srv/#{application}/shared/log/"ENV['RAILS_ENV']".log" | |
pid "/srv/#{application}/shared/tmp/pids/#{application}.pid" | |
before_fork do |server, worker| | |
f = File.open("#{server.config[:pid]}.lock", 'w') | |
exit unless f.flock(File::LOCK_SH) | |
Signal.trap 'TERM' do | |
puts 'Unicorn master intercepting TERM and sending myself QUIT instead' | |
Process.kill 'QUIT', Process.pid | |
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 | |
end |
looks awesome. However, can you explain what
stderr_path ENV['UNICORN_LOG'] if ENV['UNICORN_LOG']
stdout_path ENV['UNICORN_LOG'] if ENV['UNICORN_LOG']
pid ENV['UNICORN_LOG'] if ENV['UNICORN_PID']
does? That is confusing to me.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok, how about something like this then? It would be ideal if we could keep this in the app repo (just like sidekiq.yml) because it's easier to make changes if need-be. Consider this a rough-draft...