How do I reload Unicorn without killing the master process?
-
28-10-2019 - |
Question
I have a RubyOnRails project, and deployed it with Unicorn on nginx on an Ubuntu server.
I need to restart Unicorn if I change one of configuration files, but it makes my site shut down when I kill Unicorn's master process and start it again with bundle exec
.
Is there any way to make Unicorn work with new files without killing the process and going down?
Solution
In my capistrano deploy.rb I have:
desc "Zero-downtime restart of Unicorn"
task :restart, :except => { :no_release => true } do
run "kill -s USR2 unicorn_pid"
end
This is well documented in "Lighting fast, zero-downtime deployments with git, capistrano, nginx and Unicorn".
OTHER TIPS
Both answers, including the accepted one, are bad.
http://unicorn.bogomips.org/SIGNALS.html says send a HUP
to the master process.
desc "Zero-downtime restart of Unicorn"
task :restart, :except => { :no_release => true } do
run "kill -s HUP `cat tmp/pids/unicorn.pid`"
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow