Unicorn restart issue with capistrano

半城伤御伤魂 提交于 2019-12-03 07:25:08

问题


We're deploying with cap and using a script that send USR2 to the unicorn process to reload and it usually works but every once in a while it will fail. When that happens looking in the unicorn log reveals that it's looking for a Gemfile in an old release directory that no longer exists.

Exception :

/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)

To clarify that's not the current release but an older one that's since been removed.

When it works it does seem to work correctly - ie it does pickup the new code - so I don't think it's somehow stuck referring to the old release.

Any ideas?


回答1:


You should set the BUNDLE_GEMFILE environment variable before you start the server, point it at current/Gemfile.




回答2:


In your unicorn.rb add the before_exec block

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

before_exec do |server|
  ENV['BUNDLE_GEMFILE'] = "#{current_path}/Gemfile"
end

Read more about it here http://blog.willj.net/2011/08/02/fixing-the-gemfile-not-found-bundlergemfilenotfound-error/



来源:https://stackoverflow.com/questions/8330577/unicorn-restart-issue-with-capistrano

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!