部署应用程序时出现错误:
[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
我已将 public/images/front 包含在 repo 中,并在代码部署后用链接交换空文件夹
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
当我部署错误仍然存在,但图像出现了!