ユニコーンの `Restart`の代わりに` reload`を使ってください?
質問
ここでは、どのような状況下に展開すると、reload
シグナルをUnicornに送信したい場合は、ここでは少し混乱していますか?たとえば、私の場合のようになるでしょう:
sudo kill -s USR2 `cat /home/deploy/apps/my_app/current/tmp/pids/unicorn.pid`
.
そのPIDを殺すことで私のアプリを展開しています。
bundle exec unicorn -c config/unicorn/production.rb -E production -D
.
私はなぜリロードを使いたいのか疑問に思いますか?展開により展開のパフォーマンスを得ることができますか?
解決
Unicornを殺すとき、Unicornがバックアップするまでダウンタイムを引き起こす。USR2信号を使用するとき、Unicornは最初に新しい労働者を起動し、それから彼らが実行されたら、それは古い労働者を殺します。基本的には「オフ」ユニコーンを削除する必要があります。
注意事項は、古い労働者の殺害を処理するために、Old UnicornプロセスのPIDを含む「.oldbin」ファイルが見つかるべきであるため、Unicorn構成に記載されているbefore_fork
フックを持っているという仮定は、次のようにします。
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
. 所属していません StackOverflow