I’m a little confused about my deploy strategy here, when deploying under what circumstances would I want to send a reload signal to unicorn? For example in my case it would be like:
sudo kill -s USR2 `cat /home/deploy/apps/my_app/current/tmp/pids/unicorn.pid`
I’ve been deploying my apps by killing that pid, then starting unicorn again via something like:
bundle exec unicorn -c config/unicorn/production.rb -E production -D
I’m just wondering why I’d want to use reload? Can I gain any performance for my deployment by doing so?
When you kill unicorn you cause downtime, until unicorn can start back up. When you use the USR2 signal, unicorn starts new workers first, then once they are running, it kills the old workers. It’s basically all about removing the need to “turn off” unicorn.
Note, the assumption is that you have the documented
before_forkhook in your unicorn configuration, in order to handle the killing of the old workers, should an “.oldbin” file be found, containing the PID of the old unicorn process: