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?

有帮助吗?

解决方案

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".

其他提示

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
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top