✨ feat(script): 上传脚本,部署脚本,短链接监控配置
This commit is contained in:
@@ -18,7 +18,7 @@ const plugin: EggPlugin = {
|
||||
xtransit: {
|
||||
enable: true,
|
||||
package: 'egg-xtransit',
|
||||
env: ['sq1', 'sq4', 'sq7', 'zy1']
|
||||
env: ['sq1', 'sq4', 'sq7', 'zy1', 'ch1']
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
148
newServer.sh
Executable file
148
newServer.sh
Executable file
@@ -0,0 +1,148 @@
|
||||
#!/bin/sh
|
||||
if [ $# != 2 ] ; then
|
||||
echo "需要2个参数"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
IS_NEW_SERVER=${2}
|
||||
|
||||
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'
|
||||
# ch1
|
||||
elif [ ${1} == 'ch' ] ; then
|
||||
sshAddr=("yjz-ch-game1" "yjz-ch-game2" "yjz-ch-game3" "yjz-ch-game4" "yjz-ch-game5" "yjz-ch-game6")
|
||||
envs=("ch1" "ch2" "ch3" "ch4" "ch5" "ch6")
|
||||
masterAddr=${sshAddr[0]}
|
||||
echo ${masterAddr}
|
||||
port=22
|
||||
env='ch1'
|
||||
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
|
||||
|
||||
sshAndSetup(){
|
||||
# 如果是新服,就配置服务器环境
|
||||
if [ ${IS_NEW_SERVER} == 'true' ] ; then
|
||||
sshAddr=$1
|
||||
echo "配置服务器环境"
|
||||
ssh $sshAddr '
|
||||
npm install xtransit -g
|
||||
apt update
|
||||
apt install node-typescript
|
||||
echo '${sshAddr}' > /etc/aliashost
|
||||
mkdir /zyz_logs/xprofiler
|
||||
cd /root/zyz
|
||||
source npm-install.sh
|
||||
'
|
||||
fi
|
||||
}
|
||||
|
||||
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]}
|
||||
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}
|
||||
let "int++"
|
||||
done
|
||||
int=1
|
||||
while(( $int<=$length ))
|
||||
do
|
||||
addr=${sshAddr[$int-1]}
|
||||
curEnv=${envs[$int-1]}
|
||||
echo $curEnv $addr
|
||||
sshAndSetup $addr
|
||||
sshFun $curEnv $addr
|
||||
let "int++"
|
||||
done
|
||||
;;
|
||||
[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
|
||||
@@ -125,6 +125,43 @@ elif [ ${1} == 'zyweb4' ] ; then
|
||||
destUrl="root@yjz-zy-web4:/root/zyz/"
|
||||
port=22
|
||||
env='zy1'
|
||||
# ch1 - ch6, chweb1 - chweb3
|
||||
elif [ ${1} == 'ch1' ] ; then
|
||||
destUrl="root@yjz-ch-game1:/root/zyz/"
|
||||
port=22
|
||||
env='ch1'
|
||||
elif [ ${1} == 'ch2' ] ; then
|
||||
destUrl="root@yjz-ch-game2:/root/zyz/"
|
||||
port=22
|
||||
env='ch1'
|
||||
elif [ ${1} == 'ch3' ] ; then
|
||||
destUrl="root@yjz-ch-game3:/root/zyz/"
|
||||
port=22
|
||||
env='ch1'
|
||||
elif [ ${1} == 'ch4' ] ; then
|
||||
destUrl="root@yjz-ch-game4:/root/zyz/"
|
||||
port=22
|
||||
env='ch1'
|
||||
elif [ ${1} == 'ch5' ] ; then
|
||||
destUrl="root@yjz-ch-game5:/root/zyz/"
|
||||
port=22
|
||||
env='ch1'
|
||||
elif [ ${1} == 'ch6' ] ; then
|
||||
destUrl="root@yjz-ch-game6:/root/zyz/"
|
||||
port=22
|
||||
env='ch1'
|
||||
elif [ ${1} == 'chweb1' ] ; then
|
||||
destUrl="root@yjz-ch-web1:/root/zyz/"
|
||||
port=22
|
||||
env='ch1'
|
||||
elif [ ${1} == 'chweb2' ] ; then
|
||||
destUrl="root@yjz-ch-web2:/root/zyz/"
|
||||
port=22
|
||||
env='ch1'
|
||||
elif [ ${1} == 'chweb3' ] ; then
|
||||
destUrl="root@yjz-ch-web3:/root/zyz/"
|
||||
port=22
|
||||
env='ch1'
|
||||
elif [ ${1} == 'zymid1' ] ; then
|
||||
destUrl="root@yjz-zy-mid1:/root/zyz/"
|
||||
port=22
|
||||
|
||||
@@ -54,11 +54,15 @@ const EASY_MONITOR_TEMPLATE_FILE = './easyMonitorTemplate.js';
|
||||
const WEB_SERVER_PATH = '../web-server/config/';
|
||||
// web-server 配置模板
|
||||
const WEB_SERVER_TEMPLATE_FILE = './webServerTemplate.ts';
|
||||
// web-server plugin 配置路径
|
||||
const WEB_SERVER_PLUGIN_PATH = '../web-server/config/plugin.ts';
|
||||
|
||||
// gm-server 配置路径
|
||||
const GM_SERVER_PATH = '../gm-server/config/';
|
||||
// gm-server 配置模板
|
||||
const GM_SERVER_TEMPLATE_FILE = './gmServerTemplate.ts';
|
||||
// gm-server plugin 配置路径
|
||||
const GM_SERVER_PLUGIN_PATH = '../gm-server/config/plugin.ts';
|
||||
|
||||
// const masterData = require(GAME_SERVER_MASTER_FILE);
|
||||
const databaseData = require(GAME_SERVER_DATABASE_FILE);
|
||||
@@ -174,7 +178,7 @@ function setupGmConfig() {
|
||||
modFile(configPath, redisPassReg, `${REDIS_PASS}`);
|
||||
}
|
||||
|
||||
|
||||
// ! 尚未添加短连接 plugin 配置
|
||||
|
||||
// updateDatabase();
|
||||
// setupGameApp();
|
||||
|
||||
@@ -18,7 +18,7 @@ const plugin: EggPlugin = {
|
||||
xtransit: {
|
||||
enable: true,
|
||||
package: 'egg-xtransit',
|
||||
env: ['sq1', 'sq4', 'sq7', 'zy1']
|
||||
env: ['sq1', 'sq4', 'sq7', 'zy1', 'ch1']
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user