奇怪的问题出现了。我们48台服务器尝试从Git拉取时,会不断地收到“连接被远程主机关闭”的错误。当直接运行包含git pull代码的.sh文件时,就没有这个问题,除非它与其他拉取(*/5定时任务)同时运行。
下面是运行的.sh文件:
以下是当所有服务器尝试运行上述 .sh 文件时我们看到的错误信息:
下面是运行的.sh文件:
#!/bin/bash
BRANCH=master
BASE_DIR=/root/api
if [ ! -d $BASE_DIR ]; then
mkdir -p $BASE_DIR
fi
cd $BASE_DIR
if [ ! -d .git ]; then
git init
git remote add origin git@bitbucket.org:deximedia/api_nodejs.git
git pull origin $BRANCH
forever start $BASE_DIR/call/index.js
elif [[ $(git ls-remote origin -h refs/heads/master | awk '{ print $1 }') != $(git rev-list --max-count=1 master) ]]; then
git pull origin $BRANCH
forever stop $BASE_DIR/call/index.js
forever start $BASE_DIR/call/index.js
fi
以下是当所有服务器尝试运行上述 .sh 文件时我们看到的错误信息:
ssh_exchange_identification: Connection closed by remote host
fatal: The remote end hung up unexpectedly
ssh_exchange_identification: Connection closed by remote host
fatal: The remote end hung up unexpectedly