Unicorn重启问题与capistrano

Joh*_*iak 13 capistrano unicorn bundler

我们正在使用上限并使用一个脚本将USR2发送到unicorn进程进行重新加载,它通常可以正常工作,但每隔一段时间它就会失败.当发生这种情况时,查看unicorn日志显示它正在寻找旧版本目录中不再存在的Gemfile.

例外:

/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.21/lib/bundler/definition.rb:14:in `build': /var/www/railsapps/inventory/releases/20111128233407/Gemfile not found (Bundler::GemfileNotFound)
Run Code Online (Sandbox Code Playgroud)

澄清那不是当前的版本,而是一个旧版本已被删除.

当它工作时它似乎工作正常 - 即它确实拾取新代码 - 所以我不认为它在某种程度上卡在旧版本.

有任何想法吗?

Jho*_*ung 24

在你的unicorn.rb中添加before_exec块

current_path = "/var/www/html/my project/current"

before_exec do |server|
  ENV['BUNDLE_GEMFILE'] = "#{current_path}/Gemfile"
end
Run Code Online (Sandbox Code Playgroud)

了解更多关于在这里http://blog.willj.net/2011/08/02/fixing-the-gemfile-not-found-bundlergemfilenotfound-error/


Pat*_*her 11

您应该BUNDLE_GEMFILE在启动服务器之前设置环境变量,将其指向current/Gemfile.