I have 2 servers. The hosted rails app server and git repository server. The two servers are connected with internet (not on the same host).
The rails project are deployed with capistrano. Sometimes the remote git repository is down, I could not deploy the latest update. I also have cloned repository on the rails server, so when the remote repository server is down, I could push my changes to the repository on rails server instead.
What is the recipe so I could choose which repository to fetch.
Thanks
One way to approach this would be to set the :repository
variable on the fly.
Perhaps set up a task which gets called before deploy:update
which uses git ls-remote #{repository} #{branch}
to check whether the repository is there and responding.
Something like this (this is untested and may not work!) :
set :repos, ["git@github.com:whatever/project.git", "git@yourserver.com/repos/project.git"]
set :branch, "master"
task :select_repository do
repos.each do |repo|
if capture("git ls-remote #{repo} #{branch}") =~ /refs\/heads\/#{branch}/
set :repository, repo
return true
end
end
end
before "deploy:update" do
select_repository
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.