Use `reload` instead of` restart` for Unicorn?

I'm a little confused about my deployment strategy here, when deploying, under what circumstances do I want to send a signal to the reloadunicorn? For example, in my case, it would look like this:

sudo kill -s USR2 `cat /home/deploy/apps/my_app/current/tmp/pids/unicorn.pid`

I deploy my applications by killing this pid, and then start the unicorn again through something like:

bundle exec unicorn -c config/unicorn/production.rb -E production -D

I'm just wondering why I want to use reboot? Can I get any performance for my deployment by doing this?

+5
source share
1 answer

, , . USR2, , , , . "" .

, , before_fork , , ".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
+14

All Articles