2014-05-14 08:22:07 +00:00
|
|
|
# unicorn_rails -c config/unicorn.rb -E development -D
|
|
|
|
# kill -s USR2 PID_OF_MASTER
|
|
|
|
|
|
|
|
rails_root = `pwd`.gsub("\n", "")
|
|
|
|
|
|
|
|
rails_env = ENV['RAILS_ENV'] || 'production'
|
2014-08-29 07:40:58 +00:00
|
|
|
|
|
|
|
cpu_cores = %x(cat /proc/cpuinfo | grep processor | wc -l).sub("\n",'').to_i rescue 2
|
|
|
|
|
2014-11-07 08:06:50 +00:00
|
|
|
worker_processes (rails_env == 'production' ? 4 : 1)
|
2014-05-14 08:22:07 +00:00
|
|
|
|
2014-08-15 11:39:28 +00:00
|
|
|
# preload_app true
|
2014-05-14 08:22:07 +00:00
|
|
|
|
|
|
|
timeout 30
|
|
|
|
|
|
|
|
listen "#{rails_root}/tmp/unicorn.sock", :backlog => 2048
|
|
|
|
stderr_path "#{rails_root}/log/unicorn.log"
|
|
|
|
stdout_path "#{rails_root}/log/unicorn.log"
|
|
|
|
|
|
|
|
before_fork do |server, worker|
|
|
|
|
|
|
|
|
old_pid = "#{rails_root}/tmp/pids/unicorn.pid.oldbin"
|
|
|
|
if File.exists?(old_pid) && server.pid != old_pid
|
|
|
|
begin
|
|
|
|
Process.kill("QUIT", File.read(old_pid).to_i)
|
|
|
|
rescue Errno::ENOENT, Errno::ESRCH
|
|
|
|
end
|
|
|
|
end
|
2014-11-07 08:06:50 +00:00
|
|
|
end
|