unicorn 实现无缝重启 (unicorn.rb)config

阅读更多
1.unicorn .rb

module Rails
  class < 64
listen 5000, :tcp_nopush => false
timeout 120
pid  "#{Rails.root}/tmp/pids/unicorn.pid"

stderr_path "#{Rails.root}/log/unicorn/unicorn.stderr.log"
stdout_path "#{Rails.root}/log/unicorn/unicorn.stdout.log"


if GC.respond_to?(:copy_on_write_friendly=) 
GC.copy_on_write_friendly = true
end

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
     puts "Send 'QUIT' signal to unicorn error!"
    end
    end
end


2. 重启unicorn
 
 sudo kill -USR2 `cat tmp/pids/unicorn.pid`

 
  • unicorn.rb.tar (10 KB)
  • 下载次数: 15

你可能感兴趣的:(unicorn,nginx,hot,restart)