【问题标题】:correct way to create symlink in deploy.rb在 deploy.rb 中创建符号链接的正确方法
【发布时间】:2013-01-16 15:46:30
【问题描述】:

我在部署应用程序时出错:

    [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

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

【问题讨论】:

    标签: deployment capistrano symlink


    【解决方案1】:

    最后,我在我的存储库中包含了“public”images 目录。
    作为第 2 步,我运行我在更新 1 中指定的回调。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-24
      • 1970-01-01
      • 2012-09-12
      • 2018-09-06
      • 2017-01-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多