Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Deployment Capistrano 3:当前、链接目录和链接目录文件的相对符号链接而不是绝对符号链接_Deployment_Capistrano3 - Fatal编程技术网

Deployment Capistrano 3:当前、链接目录和链接目录文件的相对符号链接而不是绝对符号链接

Deployment Capistrano 3:当前、链接目录和链接目录文件的相对符号链接而不是绝对符号链接,deployment,capistrano3,Deployment,Capistrano3,我需要有相对的符号链接​ 而不是绝对符号链接​ 部署时 我认为需要覆盖的树任务是 Rake::Task["deploy:symlink:linked_dirs"] Rake::Task["deploy:symlink:linked_files"] Rake::Task["deploy:symlink:release"] ​ ​ 我想要的是在deploy.rb中加入一些DSL,这样当我部署时,创建的链接都是相对的。您可以在deploy.rb中使用它来覆盖默认行为 ## Use relative

我需要有相对的符号链接​ 而不是绝对符号链接​ 部署时

我认为需要覆盖的树任务是

Rake::Task["deploy:symlink:linked_dirs"]
Rake::Task["deploy:symlink:linked_files"]
Rake::Task["deploy:symlink:release"] ​ ​

我想要的是在deploy.rb中加入一些DSL,这样当我部署时,创建的链接都是相对的。

您可以在deploy.rb中使用它来覆盖默认行为

## Use relative path instead of absolute

Rake::Task["deploy:symlink:linked_dirs"].clear
Rake::Task["deploy:symlink:linked_files"].clear
Rake::Task["deploy:symlink:release"].clear

namespace :deploy do
namespace :symlink do
    desc 'Symlink release to current'
    task :release do
      on release_roles :all do
        tmp_current_path = release_path.parent.join(current_path.basename)
        execute :ln, '-s', release_path.relative_path_from(current_path.dirname), tmp_current_path
        execute :mv, tmp_current_path, current_path.parent
      end
    end

    desc 'Symlink files and directories from shared to release'
    task :shared do
      invoke 'deploy:symlink:linked_files'
      invoke 'deploy:symlink:linked_dirs'
    end

    desc 'Symlink linked directories'
    task :linked_dirs do
      next unless any? :linked_dirs
      on release_roles :all do
        execute :mkdir, '-p', linked_dir_parents(release_path)

        fetch(:linked_dirs).each do |dir|
          target = release_path.join(dir)
          source = shared_path.join(dir)
          unless test "[ -L #{target} ]"
            if test "[ -d #{target} ]"
              execute :rm, '-rf', target
            end
            execute :ln, '-s', source.relative_path_from(target.dirname), target
          end
        end
      end
    end

    desc 'Symlink linked files'
    task :linked_files do
      next unless any? :linked_files
      on release_roles :all do
        execute :mkdir, '-p', linked_file_dirs(release_path)

        fetch(:linked_files).each do |file|
          target = release_path.join(file)
          source = shared_path.join(file)
          unless test "[ -L #{target} ]"
            if test "[ -f #{target} ]"
              execute :rm, target
            end
            execute :ln, '-s', source.relative_path_from(target.dirname), target
          end
        end
      end
    end
  end
end

使用.clear将从rake任务中移除所有挂钩。如果您只想覆盖操作,请使用:
Rake::Task[“deploy:symlink:release”]。清除从中获取的操作。