增加服务器数量时出现Capistrano / Git错误

时间:2017-07-30 16:52:27

标签: git capistrano capistrano3

我使用Capistrano在生产中部署我的Rails应用程序。大约10台服务器一切正常。但是,如果我添加更多服务器(例如5),我开始从Capistrano收到错误:

Command: export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="2.2.2" GIT_ASKPASS="/bin/echo" GIT_SSH="/tmp/example/git-ssh.sh" ; /usr/bin/env git ls-remote --heads example@repo.example.com:repo/example.git

cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as example@app4.example.com: git exit status: 128
git stdout: Nothing written
git stderr: ssh_exchange_identification: read: Connection reset by peer
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

其他服务器只是克隆,因此它们具有正确的访问权限。存储库存在并且可以用较少的服务器工作。此外,当我添加新服务器时,新服务器上有时会发生同样的故障,但有时会发生在旧服务器上。因此,故障不会发生在同一台服务器上:如果我多次运行Capistrano部署,我会遇到相同的故障,但总是来自不同的服务器。

也许问题出在托管git存储库的服务器上。也许它无法处理如此多的并发ssh连接 - 为什么?有没有人遇到过这个问题?我怎样才能解决这个问题?

1 个答案:

答案 0 :(得分:1)

托管git存储库的服务器允许的最大ssh连接数存在问题。

在Ubuntu上我已编辑/etc/ssh/sshd_config,现在一切正常!添加或调整以下值:

MaxSessions 50
MaxStartups 40:30:50

有关详细信息,请参阅sshd_config。