运行上限部署时,将删除ckeditor资产目录

时间:2012-11-28 07:15:21

标签: ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.2 capistrano

我正在使用ckeditor进行微博客应用程序,并且每次运行cap deploy时都会删除ckditor目录。我如何解决这个问题,以便我可以在不删除我的vps服务器上的ckeditor资源目录的情况下运行cap deploy。

我的deploy.rb在下面。

set :whenever_command, "bundle exec whenever"
require "bundler/capistrano"
require "whenever/capistrano"

server "xxx.xx.xx.xxx", :web, :app, :db, primary: true

set :application, "cf"
set :user, "deployer"
set :deploy_to, "/home/#{user}/apps/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false

set :scm, "git"
set :repository, "git@github.com:ramza1/#{application}.git"
set :branch, "master"

default_run_options[:pty] = true
ssh_options[:forward_agent] = true

after "deploy", "deploy:cleanup" # keep only the last 5 releases

namespace :deploy do
  %w[start stop restart].each do |command|
    desc "#{command} unicorn server"
    task command, roles: :app, except: {no_release: true} do
      run "/etc/init.d/unicorn_#{application} #{command}"
    end
  end

  task :setup_config, roles: :app do
    sudo "ln -nfs #{current_path}/config/nginx.conf /etc/nginx/sites-enabled/#{application}"
    sudo "ln -nfs #{current_path}/config/unicorn_init.sh /etc/init.d/unicorn_#{application}"
    run "mkdir -p #{shared_path}/config"
    put File.read("config/database.example.yml"), "#{shared_path}/config/database.yml"
    puts "Now edit the config files in #{shared_path}."
  end
  after "deploy:setup", "deploy:setup_config"

  task :symlink_config, roles: :app do
    run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
  end
  after "deploy:finalize_update", "deploy:symlink_config"

  desc "Make sure local git is in sync with remote."
  task :check_revision, roles: :web do
    unless `git rev-parse HEAD` == `git rev-parse origin/master`
      puts "WARNING: HEAD is not the same as origin/master"
      puts "Run `git push` to sync changes."
      exit
    end
  end
  before "deploy", "deploy:check_revision"
end

2 个答案:

答案 0 :(得分:1)

如果您使用的是Capistrano 3,请将<PFFile: 0x7fed357c8580>添加到共享目录并添加符号链接:

public/ckeditor_assets

答案 1 :(得分:0)

  1. 您必须将包含资源的目录复制到共享路径。
  2. 您必须使用使用ckeditor资产指向目录的capistrano从发布路径创建符号链接
  3. 这是我做的帽子:

    after "deploy:update_code" do
      run "ln -s #{shared_path}/uploads #{release_path}/public/uploads"
    end