0

我有一个由 gem 上传的资产(通过回形针)的文件夹,它们存储在不同的文件夹ckeditor_assets中。

我想用 capistrano 处理这个文件夹,就像处理文件system夹上传回形针一样。

我怎样才能做到这一点?它将包含客户数据,因此很重要。

4

1 回答 1

1

我解决了这个问题:http ://www.simonecarletti.com/blog/2009/02/capistrano-uploads-folder/

为了将来参考,我报告了博文的一部分,它基本上在 capistranoshared文件夹中创建了一个目录,并且每次都对其进行符号链接。

# ==============================
# Uploads
# ==============================

namespace :uploads do

  desc <<-EOD
    Creates the upload folders unless they exist
    and sets the proper upload permissions.
  EOD
  task :setup, :except => { :no_release => true } do
    dirs = uploads_dirs.map { |d| File.join(shared_path, d) }
    run "#{try_sudo} mkdir -p #{dirs.join(' ')} && #{try_sudo} chmod g+w #{dirs.join(' ')}"
  end

  desc <<-EOD
    [internal] Creates the symlink to uploads shared folder
    for the most recently deployed version.
  EOD
  task :symlink, :except => { :no_release => true } do
    run "rm -rf #{release_path}/public/uploads"
    run "ln -nfs #{shared_path}/uploads #{release_path}/public/uploads"
  end

  desc <<-EOD
    [internal] Computes uploads directory paths
    and registers them in Capistrano environment.
  EOD
  task :register_dirs do
    set :uploads_dirs,    %w(uploads uploads/partners)
    set :shared_children, fetch(:shared_children) + fetch(:uploads_dirs)
  end

  after       "deploy:finalize_update", "uploads:symlink"
  on :start,  "uploads:register_dirs"

end

请参阅博文了解多阶段支持和一些说明。

于 2013-05-22T15:45:05.687 回答