miduo_gm/conf/script/deluser.sh

49 lines
1.7 KiB
Bash
Raw Normal View History

2023-07-26 17:30:12 +08:00
#!/bin/bash
#set 200 81.71.33.247 20002 "core2"
2023-08-03 15:49:18 +08:00
gameip=$1 #ip
serverid=$2 #服务器id
proccessname=$3 #corename
mongourl=$4 #mongo地址
redisIp=$5 #redis ip
redisPwd=$6 #redis 密码
echo $gameip $serverid $proccessname
2023-07-26 17:30:12 +08:00
#停游戏进程
ansible $gameip -m shell -a "supervisorctl stop $proccessname"
#删mongo数据
2023-08-03 15:49:18 +08:00
tempFile="/data/jieling/gm/config/script/clearMongo.js"
2023-07-26 17:30:12 +08:00
#if [ ! -f "$tempFile" ]; then
# touch $tempFile
# echo "print('========= 进入mongo脚本 mongoDB... ==========');" >> $tempFile
# echo "if (db.getCollection('user').count()<50){" >> $tempFile
# echo "db.getCollection('user').drop();" >> $tempFile
# echo "db.getCollection('globalSystemControl').drop();" >> $tempFile
# echo "db.getCollection('itemLog').drop();" >> $tempFile
# echo "db.getCollection('mailingSystem').drop(); " >> $tempFile
# echo "db.getCollection('server_config').drop();" >> $tempFile
# echo "db.getCollection('guildInfo').drop();" >> $tempFile
# echo "db.getCollection('guildLog').drop(); " >> $tempFile
# echo "print('========= mongoDB脚本删除成功... ==========');}" >> $tempFile
#fi
2023-08-03 15:49:18 +08:00
mongo "mongodb://""${mongourl}""/jieling_""${serverid}""?authSource=admin" $tempFile
2023-07-26 17:30:12 +08:00
#删除redis数据
2023-08-03 15:49:18 +08:00
# shellcheck disable=SC2086
2023-07-26 17:30:12 +08:00
num=$(redis-cli -h $redisIp -a $redisPwd keys $serverid"*"|wc -l)
2023-08-03 15:49:18 +08:00
echo "redis数量""$num"
if [ "$num" -lt 300 ]
2023-07-26 17:30:12 +08:00
then
2023-08-03 15:49:18 +08:00
redis-cli -h "$redisIp" -a "$redisPwd" keys "$serverid""*" | xargs -r -t -n1 redis-cli -h "$redisIp" -a "$redisPwd" del
2023-07-26 17:30:12 +08:00
echo "deleting redis data"
else
echo "too many users,can not delete success"
fi
#起游戏进程
2023-08-03 15:49:18 +08:00
ansible "$gameip" -m shell -a "supervisorctl start $proccessname"
2023-07-26 17:30:12 +08:00
#ansible 129.226.193.174 -m shell -a "/data/jieling/bin/start-all.sh core1"