在deploy.rb中创建符号链接的正确方法

时间:2013-01-16 15:46:31

标签: deployment capistrano symlink

部署应用程序时出错:

    [neon.locum.ru] executing command
*** [err :: neon.locum.ru] find: `/home/hosting_grandinvest/projects/demo/releases/20130116145843/public/images /home/hosting_grandinvest/projects/demo/releases/20130116145843/public/stylesheets /home/hosting_grandinvest/projects/demo/releases/20130116145843/public/javascripts': Нет такого файла или каталога
    command finished in 91ms
    triggering after callbacks for `deploy:update_code'
  * 2013-01-16 16:58:45 executing `make_images_link'
  * executing "ln -s /home/hosting_grandinvest/projects/demo/shared/public/images /home/hosting_grandinvest/projects/demo/releases/20130116145843/public/images"

正如你所看到的那样,因为首先它试图找到/ public / images目录。然后才为该目录创建符号链接。 开始部署我的deploy.rb

require 'bundler/capistrano'
after "deploy:update_code", :make_images_link
task :make_images_link, roles => :app do
  images_dir = "#{shared_path}/public/images"
  run "ln -s #{images_dir} #{release_path}/public/images"
end

部署完成

Gem.source_index called from /home/hosting_grandinvest/projects/demo/shared/gems/ruby/1.8/gems/rails-2.3.15/lib/rails/gem_dependency.rb:21.
master process ready
worker=0 ready
reaped #<Process::Status: pid=18656,exited(0)> worker=0
master complete

在public / images目录中找到了css(background: url(/images/front/logo.gif) no-repeat 0 0;)使用的一些文件,它们没有显示!但是当我尝试直接访问这些文件时 (http://hosting.net/images/front/logo.gif)我可以看到他们!

有关如何解决此错误并使capistrano工作的任何建议?

更新1
我在repo中包含了public / images / front,在代码部署之后将空文件夹与链接交换

after "deploy:update_code", :make_images_link
task :make_images_link, roles => :app do
  images_dir = "#{shared_path}/public/images"
  realease_images = "#{release_path}/public/images"
  run "rm -rf #{realease_images}"
  run "ln -s #{images_dir} #{realease_images}"
end

当我部署错误仍然存​​在,但图像出现了!

1 个答案:

答案 0 :(得分:0)

最后我在我的存储库中包含了'public'images'dir 并且在步骤2中,我运行了我在更新1中指定的回调。

相关问题