Deploy:symlink on capistrano points the “current” directory to previous release

僤鯓⒐⒋嵵緔 提交于 2019-12-05 01:47:24

问题


I am using capistrano to deploy my Ruby on Rails project. I am on a Dreamhost VPS and since a few weeks ago, with no change in capistrano or passenger, I began to experience a strange problem with the deployment:

Every time capistrano is deploying my application, everything goes right except deploy:symlink (which is called by default) that should point the "current" directory to the newest release. Although the new release is deployed properly to the "releases" directory, the problem is the "current" symlink is always set to previous release instead of the new one. So I can deploy apps but I always have to run the deploy two times in a row.

You can see the capistrano log here: http://img715.imageshack.us/img715/7803/capistranoproblemb.png

Has anybody else experienced this before or can help me solve it?

Thanks!


回答1:


I solved this with an additional deploy task that recreates the symlink using a different internal variable name with the correct path to the latest release (release_path instead of latest_path or something like that).


namespace :deploy do
  desc "Recreate symlink"
  task :resymlink, :roles => :app do
    run "rm -f #{current_path} && ln -s #{release_path} #{current_path}"
  end
end

after "deploy:create_symlink", "deploy:resymlink", "deploy:update_crontab"



回答2:


I think @foresth's answer is not a good solution.

I think what happens is that you're experiencing this horrible bug of capistrano.

The way to work-around the bug is the following: DO NOT READ THE latest_release VARIABLE BEFORE THE TASK deploy HAPPENS.



来源:https://stackoverflow.com/questions/3141454/deploysymlink-on-capistrano-points-the-current-directory-to-previous-release

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