Error Connecting to GitoLite from Staging Server - ECONNREFUSED Deploy Error

蹲街弑〆低调 提交于 2019-12-06 11:17:05
Tom Harrison

See update 2 below for the final answer to this question

OK, so first thing to test is whether, from your local computer, you can run git ls-remote ssh://gitolite@XXX:2011 -- it should return the list of references from the repo. If this doesn't work, it should probably give you a similar error (connection refused or similar), and then you probably need to figure out why from whoever is hosting the git repo.

If it does work locally, then you might need to set some or all of these options, depending on how you want to access git while you're deploying. I think the forward_agent option is needed unless your deploy server/user can log into the repository directly.

set :deploy_via, :remote_cache
default_run_options[:pty] = true
ssh_options[:forward_agent] = true

and I described how to set that up in this other stack overflow answer.

The key thing to remember about capistrano is that most commands are really just standard shell commands, but are passed to the remote server using ssh, as in ssh user@server.example.com <command>, so that would be another thing to test if you can't get this working.

Update based on information added to original question:

When you make a TCP connection to a server using a URL, you specify protocol, host address, and port number. Port number is implied for many protocols. E.g. ssh://1.2.3.4 specifies the protocol SSH whose standard port is 22, thus would be the same as ssh://1.2.3.4:22. I am guessing your git provider assigns different ports to different repositories (perhaps on the same IP address) in order to route requests, so for each of your repos you may have a different port number. Because it is not the default port for the ssh protocol being used, it must be specified as part of the URL (and it seems you can override this in capistrano using set :port).

It does not make sense to me that you would have multiple git repositories (repo1 and repo2) for the same project so perhaps I need to understand in what cases this happens, but in any case, the reason for the error was that your server could not make an TCP connection to the git host given the supplied URL.

Update 2 OK, so it turns out that repo1 is a git repository. It is hosted at a non-standard SSH port (2011) so this needs to embedded in the URL whenever referring to the ssh URL of the git server.

However, repo2 is actually just the application server that runs the Rails app (hosted by the same source as the git repo), and it is also available on a non-standard ssh port (1893). In order to ssh into this server, you will need to specify the port using ssh -p 1893 ... -- and since this is how capistrano connects, so will it. This is why adding the set :port, 1893 is required.

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