如何在Capistrano部署中将产品映像在生产中符号链接? [英] How do I symlink my product images in production on a Capistrano deploy?

查看:75
本文介绍了如何在Capistrano部署中将产品映像在生产中符号链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此处我收到了一个解决方案,每次使用Capistrano部署Spree Commerce应用程序时,我的图像都将被删除(它们仍然存在,但是文件夹名称错误),而我必须通过admin再次添加它们。

两者都位于该Google小组,并在回答这个问题,据说符号链接是解决方案。


您需要确保您的RAILS_ROOT / public / spree目录是
从Capistrano共享目录中符号链接的,而不是每次部署时都重新创建的
。如果没有发生此符号链接,则每次部署时,您的
映像都会丢失。


我尝试了一些



在服务器上,它们位于/ public / spree / products文件夹中。我试过的是这样:

 命名空间:deploy do 
task:start do;结束
任务:停止做;结束
任务:symlink_shared执行
运行 ln -nfs#{shared_pa​​th} / shared / spree /#{release_path} / public / spree /
结束
结束

但这是行不通的,我不知道必须输入哪个共享路径,希望有人能为您提供帮助我或提供解释链接。

解决方案

如果您使用Capistrano 3,则可以使用我在在此处



从本质上说,:shared_children 是您在Capistrano 2中的操作方式,但是由于而被删除:linked_files :linked_dirs



只需创建您的存储库中的public / spree / 目录,如果需要的话,将其添加到 .gitignore 中(无论是否跟踪它们或而不是Git),然后编辑 deploy.rb 以使用:linked_dirs

  set:linked_dirs,%w(public / spree)

这样,在Capistrano部署后,它将自动在 shared / 并将其链接到当前版本。请记住,如果需要该目录中的文件,则必须使用 rsync <这样的工具将它们手动复制到 shared / / code>。像 database.yml 这样的文件也是如此(要使用:linked_files )。


Here I received a solution to my problem that every time when I deploy my Spree Commerce app with Capistrano my images are removed (they are still there, but the folder names are wrong) and I have to add them again via admin.

Both on this Google group and in the answer to the question it is said that symlinking is solution.

You need to make sure that your RAILS_ROOT/public/spree directory is being symlinked in from the Capistrano shared directory and not recreated every time you deploy. If this symlink isn't happening, your images will be lost on every deploy.

I've tried a few things but I do not manage to symlink my images.

On the server they are in the folder /public/spree/products. What I tried is this:

namespace :deploy do
  task :start do ; end
  task :stop do ; end
  task :symlink_shared do
     run "ln -nfs #{shared_path}/shared/spree/ #{release_path}/public/spree/""
  end
end

but this does not work. I do not know which shared path I have to enter. I hope someone can help me out or provide a link with explanation.

解决方案

If you are using Capistrano 3 you can use the same method I explained in the answer to my own question here.

In essence, :shared_children was how you'd do it in Capistrano 2, but it was removed in favor of :linked_files and :linked_dirs.

Just create your public/spree/ directory in your repository, add it to .gitignore if you need to (it doesn't matter if they're tracked or not by Git), then edit your deploy.rb to use :linked_dirs:

set :linked_dirs, %w(public/spree)

This way, when Capistrano deploys it'll automatically create the directory in shared/ and link it into your current release. Please keep in mind that if you need files to be present in that directory you have to copy them to shared/ manually, using a tool like rsync. The same goes for files like database.yml (for which you'd use :linked_files).

这篇关于如何在Capistrano部署中将产品映像在生产中符号链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆