【问题标题】:ckeditor assets directory gets removed when running cap deployckeditor assets 目录在运行 cap deploy 时被删除
【发布时间】:2012-11-28 07:15:21
【问题描述】:

我正在将 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

【问题讨论】:

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


    【解决方案1】:

    如果您使用的是 Capistrano 3,请将 public/ckeditor_assets 添加到共享目录并添加符号链接:

    set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system public/ckeditor_assets}
    

    【讨论】:

      【解决方案2】:
      1. 您必须将带有资产的目录复制到共享路径。
      2. 您必须使用 capistrano 从发布路径创建符号链接,该符号链接指向带有 ckeditor 资产的目录

      这是我的帽子:

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

      【讨论】:

      • 我将如何首先将资产复制到共享部分。因为如果我按照你的方式做,我会有一个空目录
      • 我是否应该在部署之前创建一个要运行的任务:update_cod 并从 current_path 复制到 shared_pa​​th 运行之后,您必须从共享路径复制到发布路径
      • 资产不应置于版本控制之下,部署后修订目录中没有资产目录。您必须手动移动一次资产。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-05
      相关资源
      最近更新 更多