Ruby on rails 重新启动独角兽问题(capistrano)

Ruby on rails 重新启动独角兽问题(capistrano),ruby-on-rails,ruby-on-rails-3,capistrano,unicorn,Ruby On Rails,Ruby On Rails 3,Capistrano,Unicorn,我在deploy.rb中有以下设置来重新启动服务器: 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 unicor

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

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

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

这可能是因为unicorn重新启动的方式。并不是每个工作进程都会立即重新启动。这是为了使零停机时间和无请求丢失成为可能。如果您确实希望看到更改,请尝试停止,然后启动应用程序。我不得不这样做了好几次。当然,您可能会失去一些请求

以下任务是我用来重新启动、停止和启动unicorn服务器的任务

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
希望这对你有帮助

也许这篇文章很有趣。

您应该试一试,这就是我目前使用的下面提到的默认挂钩

安装程序 将库添加到您的
文件中

ruby
小组:发展怎么办
gem'capistrano unicorn',:require=>false
结束

并将其加载到部署脚本
config/deploy.rb

ruby
需要“卡皮斯特拉诺独角兽”

添加unicorn重新启动任务挂钩:

ruby
在“部署:重新启动”、“独角兽:重新加载”之后#应用程序未预加载
在“部署:重新启动”、“独角兽:重新启动”之后#预加载应用程序
在“部署:重新启动”、“独角兽:重复”之后#在实施"叉钩"之前(零停机部署)

看到我的宝贝了吗~

请记住:unicorn.rb中的工作目录应该是:/your/cap/directory/current

不是:文件。展开\u路径(“....”,文件)


因为unicorn和linux软链接分叉错误:软链接不能很好地工作。

我也有同样的问题,而且我只运行了一个worker,所以我猜不可能是这样。