重启 Unicorn 问题 (capistrano)
我在 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
但它不起作用。我的意思是该命令执行(它询问我密码并且没有给出错误),但配置文件中的所有更改仍然被忽略(即工作进程或数据库设置的数量)。
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).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许这是因为独角兽重启的方式。并非每个工作人员都会立即重新启动。这是为了实现零停机且不丢失任何请求。如果您想确实看到所做的更改,请尝试停止然后启动您的应用程序。有时我不得不这样做。当然,您可能会失去一些请求。
以下任务是我用于重新启动、停止和启动我的 unicorn 服务器的任务。
希望这对您有帮助。
也许这个< /a> 文章很有趣。
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.
Hope this helps you.
Maybe this article is of interest.
看这里我的宝贝~
使用 USR2 重新启动 Unicorn 似乎不会重新加载Production.rb 设置
请记住:unicorn.rb 中的工作目录应该是:/your/cap/directory/current
而不是: File.expand_path("../..", FILE)
因为unicorn和linux软链接fork错误:软链接无法正常工作。
see here my baby~
Restarting Unicorn with USR2 doesn't seem to reload production.rb settings
Keep in mind that: your working directory in unicorn.rb should be : /your/cap/directory/current
NOT be: File.expand_path("../..", FILE)
Because the unicorn and linux soft link forking error: soft link can not work well.
你应该尝试 capistrano-unicorn ,这就是我目前使用下面提到的默认钩子的方法。
设置
将库添加到您的
Gemfile
:ruby
组:开发做
gem 'capistrano-unicorn', :require =>;错误的
结尾
并将其加载到您的部署脚本中
config/deploy.rb
:ruby
需要“capistrano-unicorn”
添加 unicorn 重启任务钩子:
ruby
在 'deploy:restart', 'unicorn:reload' 之后 # 应用程序未预加载
在 'deploy:restart', 'unicorn:restart' 之后 # 应用程序已预加载
after 'deploy:restart', 'unicorn:duplicate' # before_fork 钩子实现(零停机部署)
You should give capistrano-unicorn a try, that's what I currently use with the default hooks mentioned below.
Setup
Add the library to your
Gemfile
:ruby
group :development do
gem 'capistrano-unicorn', :require => false
end
And load it into your deployment script
config/deploy.rb
:ruby
require 'capistrano-unicorn'
Add unicorn restart task hook:
ruby
after 'deploy:restart', 'unicorn:reload' # app IS NOT preloaded
after 'deploy:restart', 'unicorn:restart' # app preloaded
after 'deploy:restart', 'unicorn:duplicate' # before_fork hook implemented (zero downtime deployments)