首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

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

2012-07-03 
unicorn 实现无缝重启 (unicorn.rb)config1.unicorn .rbmodule Railsclass selfdef rootFile.expand_pat

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

module Rails  class <<self    def root        File.expand_path(__FILE__).split('/')[0..-3].join('/')    end  endendrails_env = ENV['RAILS_ENV'] || 'production'worker_processes (rails_env == 'production' ? 10 : 2)preload_app trueworking_directory Rails.rootlisten "#{Rails.root}/tmp/nginx/sockets/unicorn.sock", :backlog => 64listen 5000, :tcp_nopush => falsetimeout 120pid  "#{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 = trueendbefore_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    endend


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

 

热点排行