重新启动Unicorn问题(capistrano) [英] Restart Unicorn issue (capistrano)

查看:146
本文介绍了重新启动Unicorn问题(capistrano)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 deploy.rb 中进行了以下设置来重新启动服务器:

I've got following settings in deploy.rb to restart my server:

namespace :deploy do
  task :restart do
    run "if [ -f #{unicorn_pid} ] && [ -e /proc/$(cat #{unicorn_pid}) ]; then kill -USR2     \`cat #{unicorn_pid}\`; else cd #{deploy_to}/current && bundle exec unicorn -c #{unicorn_conf} -    E #{rails_env} -D; fi"
  end
end

但这不起作用。我的意思是该命令执行了(它询问我密码并且没有给出错误),但是配置文件中的所有更改仍然被忽略(即工作进程或数据库设置的数量)。

but it doesn't work. I mean that command executes (it asks me the password and gives no errors), but all changes in config files are still ignored (i.e. number of worker processes or database settings).

推荐答案

也许这是由于独角兽重新启动的原因。并非每个工作者都立即重新启动。这样可以使停机时间为零,并且不产生任何请求。如果要确定要查看更改,请尝试停止然后再启动应用程序。我不得不做几次。当然,您可能会释放一些请求。

Maybe this is because of the way unicorn restarts. Not every worker is restarted immediately. This is to make it possible to have zero downtime and loose no requests. If you want to see your changes for sure, try to stop and then start your application instead. I have had to do this some times. Of course you will potentially loose some request.

以下任务是我用来重新启动,停止和启动我的独角兽服务器的任务。

The following tasks is what I use for restarting, stopping, and starting my unicorn server.

desc "Zero-downtime restart of Unicorn"
task :restart, :except => { :no_release => true } do
  run "kill -s USR2 `cat #{shared_path}/pids/unicorn.pid`"
end

desc "Start unicorn"
task :start, :except => { :no_release => true } do
  run "cd #{current_path} ; bundle exec unicorn_rails -c config/unicorn.rb -D -E production"
end

desc "Stop unicorn"
task :stop, :except => { :no_release => true } do
  run "kill -s QUIT `cat #{shared_path}/pids/unicorn.pid`"
end

希望这对您有所帮助。

也许这篇文章很有趣。

这篇关于重新启动Unicorn问题(capistrano)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆