🐳 chore(脚本): 批量自动重启脚本
This commit is contained in:
114
pushAndRestart.sh
Executable file
114
pushAndRestart.sh
Executable file
@@ -0,0 +1,114 @@
|
||||
#!/bin/sh
|
||||
if [ $# != 1 ] ; then
|
||||
echo "需要1个参数"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
port=22
|
||||
env=${1}
|
||||
sshAddr=()
|
||||
envs=()
|
||||
masterAddr=''
|
||||
|
||||
if [ ${1} == 'zy' ] ; then
|
||||
sshAddr=( "yjz-zy-game1" "yjz-zy-game2" "yjz-zy-game3" "yjz-zy-game4" "yjz-zy-game5")
|
||||
envs=("zy1" "zy2" "zy3" "zy4" "zy5")
|
||||
masterAddr=${sshAddr[0]}
|
||||
echo ${masterAddr}
|
||||
port=22
|
||||
env='zy1'
|
||||
elif [ ${1} == 'alpha' ] ; then
|
||||
sshAddr=("zyzalpha")
|
||||
envs=("alpha")
|
||||
masterAddr=${sshAddr[0]}
|
||||
echo ${masterAddr}
|
||||
port=22
|
||||
env='alpha'
|
||||
elif [ ${1} == 'dev' ] ; then
|
||||
sshAddr=("zyzdev")
|
||||
envs=("dev")
|
||||
masterAddr=${sshAddr[0]}
|
||||
echo ${masterAddr}
|
||||
port=22
|
||||
env='dev'
|
||||
else
|
||||
echo "需要一个参数指明服务器"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
echo "|*********************|\n"
|
||||
|
||||
if branch=$(git symbolic-ref --short -q HEAD)
|
||||
then
|
||||
echo "git on branch $branch \n"
|
||||
else
|
||||
echo "git not on any branch \n"
|
||||
fi
|
||||
echo "|*********************|\n"
|
||||
|
||||
echo "and config.json is: \n"
|
||||
node ./config.js ${env} ${1}
|
||||
cat './game-server/config.json'
|
||||
echo "\n"
|
||||
echo "|*********************|\n"
|
||||
|
||||
echo "and server_const is \n"
|
||||
cat './shared/resource/jsons/server_const.json' | grep DEBUG_PAY
|
||||
cat './shared/resource/jsons/server_const.json' | grep DEBUG_TIME
|
||||
cat './shared/resource/jsons/server_const.json' | grep CHECK_WORD
|
||||
cat './shared/resource/jsons/server_const.json' | grep CAN_PAY
|
||||
cat './shared/resource/jsons/server_const.json' | grep SKIP_ENCODE
|
||||
echo "\n"
|
||||
echo "|*********************|"
|
||||
|
||||
read -r -p "Are You Sure? [Y/n]" input
|
||||
|
||||
sshFun(){
|
||||
curEnv=$1
|
||||
sshAddr=$2
|
||||
echo $curEnv $env
|
||||
if [ $curEnv == $env ]
|
||||
then
|
||||
ssh $sshAddr '
|
||||
cd /root/zyz/game-server
|
||||
pm2 kill
|
||||
./pm2Starter.sh
|
||||
'
|
||||
else
|
||||
ssh $sshAddr '
|
||||
cd /root/zyz/game-server
|
||||
pm2 kill
|
||||
./pm2StarterDistribute.sh '${env} ${curEnv}'
|
||||
'
|
||||
fi
|
||||
}
|
||||
|
||||
case $input in
|
||||
[yY][eE][sS]|[yY])
|
||||
echo "Yes"
|
||||
length=${#sshAddr[@]}
|
||||
int=1
|
||||
while(( $int<=$length ))
|
||||
do
|
||||
addr=${sshAddr[$int-1]}
|
||||
curEnv=${envs[$int-1]}
|
||||
destUrl='root@'${addr}':/root/zyz/'
|
||||
echo $destUrl
|
||||
rsync -av --include '.babelrc' --include '.eslintrc.js' --exclude-from='exclude-file.txt' --progress --inplace --no-owner --no-group --rsh='ssh -p'${port} . ${destUrl}
|
||||
sshFun $curEnv $addr
|
||||
let "int++"
|
||||
done
|
||||
echo '$$$'
|
||||
;;
|
||||
[nN][oO]|[nN])
|
||||
echo "No"
|
||||
;;
|
||||
*)
|
||||
echo "Invalid input"
|
||||
;;
|
||||
esac
|
||||
|
||||
git checkout ./game-server/config.json
|
||||
git checkout ./gm-server/config/env
|
||||
git checkout ./web-server/config/env
|
||||
git checkout ./web-server/config/sshHost.ts
|
||||
Reference in New Issue
Block a user