Everytime I run cap deploy in the remote server I lost some unversioned files because capistrano creates a new directory and checkouts the head revision in it. But there are some files that are not versioned like users avatars (paperclip) and uploaded images which don't get copied to the new current release.
每次我在远程服务器上运行cap deploy时,我都会丢失一些未版本控制的文件,因为capistrano会创建一个新目录并检查其中的头部修订。但是有一些文件没有版本化,如用户头像(回形针)和上传的图像,不会被复制到新的当前版本。
How can I workaround this?
我该如何解决这个问题?
Thanks!
14
Personally, I think the best way to deal with those kind of things is to store them in the shared folder and create a task in capistrano to create symlinks to the shared assets.
就个人而言,我认为处理这类事情的最佳方法是将它们存储在共享文件夹中,并在capistrano中创建一个任务,以创建共享资产的符号链接。
Here's an example from one of my projects:
以下是我的一个项目的示例:
set :shared_assets, %w{public/images/products public/images/barcodes}
namespace :assets do
namespace :symlinks do
desc "Setup application symlinks for shared assets"
task :setup, :roles => [:app, :web] do
shared_assets.each { |link| run "mkdir -p #{shared_path}/#{link}" }
end
desc "Link assets for current deploy to the shared location"
task :update, :roles => [:app, :web] do
shared_assets.each { |link| run "ln -nfs #{shared_path}/#{link} #{release_path}/#{link}" }
end
end
end
before "deploy:setup" do
assets.symlinks.setup
end
before "deploy:symlink" do
assets.symlinks.update
end
8
Adding your paths to shared_children also works and is actually just a one-liner in your deploy.rb:
将您的路径添加到shared_children也可以,并且实际上只是deploy.rb中的一行代码:
set :shared_children, shared_children + %w{public/uploads}
found it here: astonj
在这里找到了:astonj
0
Here is very tiny and useful gem: https://github.com/teohm/capistrano-shared_file. Check the gem's docs — everything is simple.
这是一个非常小而有用的gem:https://github.com/teohm/capistrano-shared_file。检查gem的文档 - 一切都很简单。
Install gem, in deploy.rb
require it and just provide an array of files you wish to share between releases in shared_files
option:
安装gem,在deploy.rb中需要它,并在shared_files选项中提供您希望在发行版之间共享的文件数组:
set :shared_files, %w(config/database.yml)
Store your files at <project_dir>/shared/files/YOUR_FILE_GOES_HERE
. And they will be symlinked to root of your application at each deploy. Thats all.
将文件存储在
本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2011/01/10/144c99bcb5543f9278191b38cdc60125.html。