Reputation: 916
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?
Upvotes: 9
Views: 12713
Reputation: 18765
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".
Upvotes: 8
Reputation:
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
Upvotes: 3