Capistrano deploy to different path on same server

若如初见. 提交于 2019-12-23 12:14:37

问题


I am trying to deploy my application using capistrano. But I want to deploy my application to multiple paths of the same server.For example If for the first run I want to deploy it to below path

set :deploy_to, '/home/a/some_path/

Once completed the first one it should run for the second path that will be

 set :deploy_to, '/home/b/some_path/

and so on. Any suggestions how can I achieve this? Right now my single path deployment path is working AOK.


回答1:


In your config file:

set :deploy_to, ENV["DEPLOY_PATH"]

Then, to deploy, run the command setting the DEPLOY_PATH variable:

DEPLOY_PATH="my/path" cap production deploy



回答2:


Using capistrano 3.8.2, I monkeypatched lib/capistrano/dsl/paths.rb in my deploy.rb, but then I found that I needed more work to get git wrapper set up right when there where different deploy users. The result is at: https://gist.github.com/mcr/49e8c7034658120013c1fe49da77c2ac

But, I'm leaving the essence of the content here:

module Capistrano
  module DSL
    module Paths
      def deploy_to
        dir = @host.properties.fetch(:deploy_to) || fetch(:deploy_to)
        puts "For #{@host.hostname} deploy_to: #{dir}"
        dir
      end
    end
  end
end

(You can take the puts out, and shorten it to a one-liner, but I found the extra debug useful)

One then does:

server "server.client1.example.com", user: "client1", roles: %w{app db web}, deploy_to: '/client1/app/foobar'
server "server.client2.example.com", user: "client2", roles: %w{app db web}, deploy_to: '/client2/app/foobar'

where server.client1.example.com and server.client2.example.com are CNAMEs or duplicate A/AAAA records for the same server. This also isolates the question of where each client is to DNS.



来源:https://stackoverflow.com/questions/27635764/capistrano-deploy-to-different-path-on-same-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!