对于Unicorn,使用`reload`而不是`restart`?

JP *_*shy 5 ruby unicorn

我在这里部署策略有些困惑,在什么情况下部署我想reload向独角兽发送信号?例如在我的情况下,它将是:

sudo kill -s USR2 `cat /home/deploy/apps/my_app/current/tmp/pids/unicorn.pid`
Run Code Online (Sandbox Code Playgroud)

我一直在通过杀死那个pid来部署我的应用程序,然后通过以下方式再次启动独角兽:

bundle exec unicorn -c config/unicorn/production.rb -E production -D
Run Code Online (Sandbox Code Playgroud)

我只是想知道为什么我要使用重装?这样做可以为我的部署获得任何性能吗?

d11*_*wtq 14

当你杀死独角兽时,你会导致停机,直到独角兽可以重新开始.当你使用USR2信号时,独角兽首先启动新工人,然后一旦他们运行,就会杀死旧工人.它基本上都是为了消除"关闭"独角兽的需要.

注意,假设您before_fork在unicorn配置中有记录的钩子,以便处理旧工作者的杀死,如果找到".oldbin"文件,则包含旧的独角兽进程的PID:

before_fork do |server, worker|
  # a .oldbin file exists if unicorn was gracefully restarted with a USR2 signal
  # we should terminate the old process now that we're up and running
  old_pid = "#{pids_dir}/unicorn.pid.oldbin"
  if File.exists?(old_pid)
    begin
      Process.kill("QUIT", File.read(old_pid).to_i)
    rescue Errno::ENOENT, Errno::ESRCH
      # someone else did our job for us
    end
  end
end
Run Code Online (Sandbox Code Playgroud)