generated from root/miduo_server
gm清库脚本
parent
22e5daff2b
commit
db1793bf9e
|
|
@ -0,0 +1,12 @@
|
||||||
|
print('========= operate mongoDB... ==========');
|
||||||
|
if (db.getCollection('user').count()<50){
|
||||||
|
//mongoDB
|
||||||
|
db.getCollection('user').drop();
|
||||||
|
db.getCollection('globalSystemControl').drop();
|
||||||
|
db.getCollection('itemLog').drop();
|
||||||
|
db.getCollection('mailingSystem').drop();
|
||||||
|
db.getCollection('server_config').drop();
|
||||||
|
db.getCollection('guildInfo').drop();
|
||||||
|
db.getCollection('guildLog').drop();
|
||||||
|
print('========= mongoDB删除成功... ==========');
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#set 200 81.71.33.247 20002 "core2"
|
||||||
|
gameip=$1 #游戏服ip
|
||||||
|
serverid=$2 #游戏服id
|
||||||
|
proccessname=$3 #core1
|
||||||
|
echo $gameip $serverid $proccessname
|
||||||
|
|
||||||
|
##这里是所有的动态参数,根据游戏服做修改
|
||||||
|
mongourl=$4
|
||||||
|
redisIp=$5
|
||||||
|
redisPwd=$6
|
||||||
|
|
||||||
|
#停游戏进程
|
||||||
|
ansible $gameip -m shell -a "supervisorctl stop $proccessname"
|
||||||
|
|
||||||
|
#删mongo数据
|
||||||
|
tempFile="clearMongo.js"
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
|
mongo "mongodb://"$mongourl"/jieling_"$serverid"?authSource=admin" $tempFile
|
||||||
|
|
||||||
|
#删除redis数据
|
||||||
|
num=$(redis-cli -h $redisIp -a $redisPwd keys $serverid"*"|wc -l)
|
||||||
|
echo "redis数量"$num
|
||||||
|
if [ $num -lt 500 ]
|
||||||
|
then
|
||||||
|
redis-cli -h $redisIp -a $redisPwd keys $serverid"*" | xargs redis-cli -h $redisIp -a $redisPwd del
|
||||||
|
echo "deleting redis data"
|
||||||
|
else
|
||||||
|
echo "too many users,can not delete success"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#起游戏进程
|
||||||
|
ansible $gameip -m shell -a "supervisorctl start $proccessname"
|
||||||
|
#ansible 129.226.193.174 -m shell -a "/data/jieling/bin/start-all.sh core1"
|
||||||
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
gameip=$1
|
||||||
|
proccessname=$2
|
||||||
|
ansible $gameip -m shell -a "supervisorctl restart $proccessname"
|
||||||
|
|
@ -5,7 +5,6 @@ import com.jmfy.controller.GlobalSysController;
|
||||||
import com.jmfy.controller.LoginController;
|
import com.jmfy.controller.LoginController;
|
||||||
import com.jmfy.handler.BaseHandler;
|
import com.jmfy.handler.BaseHandler;
|
||||||
import com.jmfy.handler.ManagerManager;
|
import com.jmfy.handler.ManagerManager;
|
||||||
import com.jmfy.handler.RedisLogic;
|
|
||||||
import com.jmfy.thrift.pool.ThriftPoolUtils;
|
import com.jmfy.thrift.pool.ThriftPoolUtils;
|
||||||
import com.jmfy.utils.*;
|
import com.jmfy.utils.*;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
|
|
@ -17,8 +16,6 @@ import org.springframework.boot.web.support.SpringBootServletInitializer;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,6 @@ public class ChannelInfoController {
|
||||||
@Resource
|
@Resource
|
||||||
private CUserDao cUserDao;
|
private CUserDao cUserDao;
|
||||||
@Resource
|
@Resource
|
||||||
private CommonManager commonManager;
|
|
||||||
@Resource
|
|
||||||
private SeqUtils seqUtils;
|
private SeqUtils seqUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -77,7 +75,7 @@ public class ChannelInfoController {
|
||||||
int insertChannelInfo(HttpServletRequest request) throws Exception {
|
int insertChannelInfo(HttpServletRequest request) throws Exception {
|
||||||
HashMap<String, String> map = JsonUtil.getInstence().getParameterMap(request);
|
HashMap<String, String> map = JsonUtil.getInstence().getParameterMap(request);
|
||||||
// 验证权限
|
// 验证权限
|
||||||
boolean verifyPower = commonManager.verifyPower(request, PowersEnum.ADD_CHANNEL_PERMISSIONS);
|
boolean verifyPower = CommonManager.verifyPower(request, PowersEnum.ADD_CHANNEL_PERMISSIONS);
|
||||||
if (!verifyPower){
|
if (!verifyPower){
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
@ -114,7 +112,7 @@ public class ChannelInfoController {
|
||||||
int updateChannel(HttpServletRequest request) throws Exception {
|
int updateChannel(HttpServletRequest request) throws Exception {
|
||||||
HashMap<String, String> map = JsonUtil.getInstence().getParameterMap(request);
|
HashMap<String, String> map = JsonUtil.getInstence().getParameterMap(request);
|
||||||
// 验证权限
|
// 验证权限
|
||||||
boolean verifyPower = commonManager.verifyPower(request, PowersEnum.UPDATE_CHANNEL_PERMISSIONS);
|
boolean verifyPower = CommonManager.verifyPower(request, PowersEnum.UPDATE_CHANNEL_PERMISSIONS);
|
||||||
if (!verifyPower){
|
if (!verifyPower){
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
@ -168,7 +166,7 @@ public class ChannelInfoController {
|
||||||
int deleteChannelInfo(HttpServletRequest request) throws Exception {
|
int deleteChannelInfo(HttpServletRequest request) throws Exception {
|
||||||
HashMap<String, String> map = JsonUtil.getInstence().getParameterMap(request);
|
HashMap<String, String> map = JsonUtil.getInstence().getParameterMap(request);
|
||||||
// 验证权限
|
// 验证权限
|
||||||
boolean verifyPower = commonManager.verifyPower(request, PowersEnum.DELETE_CHANNEL_PERMISSIONS);
|
boolean verifyPower = CommonManager.verifyPower(request, PowersEnum.DELETE_CHANNEL_PERMISSIONS);
|
||||||
if (!verifyPower){
|
if (!verifyPower){
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,11 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
public class CommonManager {
|
public class CommonManager {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(CommonManager.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(CommonManager.class);
|
||||||
|
|
||||||
@Resource
|
private static CUserDao cUserDao;
|
||||||
private CUserDao cUserDao;
|
|
||||||
|
public CommonManager(CUserDao cUserDao){
|
||||||
|
CommonManager.cUserDao = cUserDao;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证权限
|
* 验证权限
|
||||||
|
|
@ -29,7 +32,7 @@ public class CommonManager {
|
||||||
* @param powersEnum
|
* @param powersEnum
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean verifyPower(HttpServletRequest request, PowersEnum... powersEnum) throws Exception {
|
public static boolean verifyPower(HttpServletRequest request, PowersEnum... powersEnum) throws Exception {
|
||||||
String username = (String) request.getSession().getAttribute("username");
|
String username = (String) request.getSession().getAttribute("username");
|
||||||
if (username == null){
|
if (username == null){
|
||||||
LOGGER.error("用户不存在,操作失败");
|
LOGGER.error("用户不存在,操作失败");
|
||||||
|
|
|
||||||
|
|
@ -43,10 +43,6 @@ public class ServerInfoController {
|
||||||
@Resource
|
@Resource
|
||||||
private ServerInfoDao serverInfoDao;
|
private ServerInfoDao serverInfoDao;
|
||||||
@Resource
|
@Resource
|
||||||
private CommonManager commonManager;
|
|
||||||
@Resource
|
|
||||||
private AutoServerManager autoServerManager;
|
|
||||||
@Resource
|
|
||||||
private CUserDao cUserDao;
|
private CUserDao cUserDao;
|
||||||
|
|
||||||
private static int state = 0;
|
private static int state = 0;
|
||||||
|
|
@ -182,7 +178,7 @@ public class ServerInfoController {
|
||||||
@RequestMapping(value = "/deleteServer", method = {RequestMethod.POST, RequestMethod.GET})
|
@RequestMapping(value = "/deleteServer", method = {RequestMethod.POST, RequestMethod.GET})
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
int deleteServer(HttpServletRequest request) throws Exception {
|
int deleteServer(HttpServletRequest request) throws Exception {
|
||||||
boolean power = commonManager.verifyPower(request, PowersEnum.DELETE_SERVER_PERMISSIONS);
|
boolean power = CommonManager.verifyPower(request, PowersEnum.DELETE_SERVER_PERMISSIONS);
|
||||||
if (!power){
|
if (!power){
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
@ -203,7 +199,7 @@ public class ServerInfoController {
|
||||||
@RequestMapping(value = "/transferServer", method = {RequestMethod.POST, RequestMethod.GET})
|
@RequestMapping(value = "/transferServer", method = {RequestMethod.POST, RequestMethod.GET})
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
int transferServer(HttpServletRequest request) throws Exception {
|
int transferServer(HttpServletRequest request) throws Exception {
|
||||||
boolean power = commonManager.verifyPower(request, PowersEnum.TRANSFER_SERVER_PERMISSIONS);
|
boolean power = CommonManager.verifyPower(request, PowersEnum.TRANSFER_SERVER_PERMISSIONS);
|
||||||
if (!power){
|
if (!power){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -251,7 +247,7 @@ public class ServerInfoController {
|
||||||
int notState = ServerStatusEnum.NOT_OPERATE.getId();
|
int notState = ServerStatusEnum.NOT_OPERATE.getId();
|
||||||
// 正常状态转向未运营状态,验证权限
|
// 正常状态转向未运营状态,验证权限
|
||||||
if (info.getStatusInt() != notState && vo.getStatusInt() == notState){
|
if (info.getStatusInt() != notState && vo.getStatusInt() == notState){
|
||||||
boolean verifyPower = commonManager.verifyPower(request, PowersEnum.SERVER_NOT_OPERATION);
|
boolean verifyPower = CommonManager.verifyPower(request, PowersEnum.SERVER_NOT_OPERATION);
|
||||||
String account = String.valueOf(request.getSession().getAttribute("username"));
|
String account = String.valueOf(request.getSession().getAttribute("username"));
|
||||||
CAdmin admin = cUserDao.findAdmin(account);
|
CAdmin admin = cUserDao.findAdmin(account);
|
||||||
if (!verifyPower || admin == null || admin.getIdentity() != IdentityEnum.SYSTEM_ADMIN.getId()){
|
if (!verifyPower || admin == null || admin.getIdentity() != IdentityEnum.SYSTEM_ADMIN.getId()){
|
||||||
|
|
@ -269,7 +265,7 @@ public class ServerInfoController {
|
||||||
ServerInfoVo infoVo = createServerVo(info, 0);
|
ServerInfoVo infoVo = createServerVo(info, 0);
|
||||||
if (!vo.getOpenTime().equals(infoVo.getOpenTime())){
|
if (!vo.getOpenTime().equals(infoVo.getOpenTime())){
|
||||||
serverInfoDao.updateOpenServerTime(vo.getServer_id(),vo.getOpenTime());
|
serverInfoDao.updateOpenServerTime(vo.getServer_id(),vo.getOpenTime());
|
||||||
autoServerManager.rebootServer(info.getServer_id());
|
AutoServerManager.rebootServer(info.getServer_id());
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
RedisLogic.updateGmGroupId(vo.getServer_id(),vo.getCrossGroupId());
|
RedisLogic.updateGmGroupId(vo.getServer_id(),vo.getCrossGroupId());
|
||||||
|
|
@ -312,7 +308,7 @@ public class ServerInfoController {
|
||||||
break;
|
break;
|
||||||
case "-3":// -3表示重启全部服务器
|
case "-3":// -3表示重启全部服务器
|
||||||
TaskKit.scheduleWithFixedOne(()->GMHandler.sendGm(id,"kick 0"),0);
|
TaskKit.scheduleWithFixedOne(()->GMHandler.sendGm(id,"kick 0"),0);
|
||||||
autoServerManager.rebootServer(id);
|
AutoServerManager.rebootServer(id);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// 修改服务器信息
|
// 修改服务器信息
|
||||||
|
|
@ -375,7 +371,7 @@ public class ServerInfoController {
|
||||||
@RequestMapping(value = "/cleanupServer", method = {RequestMethod.POST, RequestMethod.GET})
|
@RequestMapping(value = "/cleanupServer", method = {RequestMethod.POST, RequestMethod.GET})
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
int cleanupServer(HttpServletRequest request) throws Exception {
|
int cleanupServer(HttpServletRequest request) throws Exception {
|
||||||
boolean power = commonManager.verifyPower(request, PowersEnum.CLEANUP_SERVER_PERMISSIONS);
|
boolean power = CommonManager.verifyPower(request, PowersEnum.CLEANUP_SERVER_PERMISSIONS);
|
||||||
if (!power){
|
if (!power){
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
@ -391,7 +387,7 @@ public class ServerInfoController {
|
||||||
}
|
}
|
||||||
// 2. 清库
|
// 2. 清库
|
||||||
ServerInfoVo serverInfoVo = createServerVo(info,1);
|
ServerInfoVo serverInfoVo = createServerVo(info,1);
|
||||||
TaskKit.scheduleWithFixedOne(()->autoServerManager.manualStartServer(serverInfoVo),0);
|
TaskKit.scheduleWithFixedOne(()->AutoServerManager.manualStartServer(serverInfoVo),0);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -522,7 +518,7 @@ public class ServerInfoController {
|
||||||
@RequestMapping(value = "/updateAutoServerSetting", method = {RequestMethod.POST, RequestMethod.GET})
|
@RequestMapping(value = "/updateAutoServerSetting", method = {RequestMethod.POST, RequestMethod.GET})
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
int updateAutoServerSetting(@RequestBody AutoServerSetting setting,HttpServletRequest request) throws Exception {
|
int updateAutoServerSetting(@RequestBody AutoServerSetting setting,HttpServletRequest request) throws Exception {
|
||||||
boolean power = commonManager.verifyPower(request, PowersEnum.AUTO_START_SERVER_PERMISSIONS);
|
boolean power = CommonManager.verifyPower(request, PowersEnum.AUTO_START_SERVER_PERMISSIONS);
|
||||||
if (!power){
|
if (!power){
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
@ -539,13 +535,13 @@ public class ServerInfoController {
|
||||||
@RequestMapping(value = "/restartServer", method = {RequestMethod.POST, RequestMethod.GET})
|
@RequestMapping(value = "/restartServer", method = {RequestMethod.POST, RequestMethod.GET})
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
int restartServer(HttpServletRequest request) throws Exception {
|
int restartServer(HttpServletRequest request) throws Exception {
|
||||||
boolean power = commonManager.verifyPower(request, PowersEnum.RESTART_SERVER_PERMISSIONS);
|
boolean power = CommonManager.verifyPower(request, PowersEnum.RESTART_SERVER_PERMISSIONS);
|
||||||
if (!power){
|
if (!power){
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
String serverId = request.getParameter("serverId");
|
String serverId = request.getParameter("serverId");
|
||||||
return autoServerManager.rebootServer(serverId);
|
return AutoServerManager.rebootServer(serverId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package com.jmfy.utils;
|
||||||
|
|
||||||
import com.jmfy.controller.LoginController;
|
import com.jmfy.controller.LoginController;
|
||||||
import com.jmfy.dao.ServerInfoDao;
|
import com.jmfy.dao.ServerInfoDao;
|
||||||
import com.jmfy.handler.DingTalkLogic;
|
|
||||||
import com.jmfy.model.AutoServerSetting;
|
import com.jmfy.model.AutoServerSetting;
|
||||||
import com.jmfy.model.CServerOpenTime;
|
import com.jmfy.model.CServerOpenTime;
|
||||||
import com.jmfy.model.ServerInfo;
|
import com.jmfy.model.ServerInfo;
|
||||||
|
|
@ -11,9 +10,10 @@ import com.jmfy.model.vo.ServerStatusEnum;
|
||||||
import com.jmfy.redisProperties.RedisUserKey;
|
import com.jmfy.redisProperties.RedisUserKey;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -29,15 +29,39 @@ import java.util.stream.Collectors;
|
||||||
public class AutoServerManager {
|
public class AutoServerManager {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(AutoServerManager.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(AutoServerManager.class);
|
||||||
|
|
||||||
private AutoServerManager() {
|
private static ServerInfoDao serverInfoDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public AutoServerManager(ServerInfoDao serverInfoDao) {
|
||||||
|
AutoServerManager.serverInfoDao = serverInfoDao;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Instance {
|
private static String gameMongodb;
|
||||||
public final static AutoServerManager instance = new AutoServerManager();
|
public static String getGameMongodb() {
|
||||||
|
String[] split = gameMongodb.split("/");
|
||||||
|
return split[2];
|
||||||
|
}
|
||||||
|
@Value("${spring.data.gameMongodb.uri}")
|
||||||
|
public void setGameMongodb(String gameMongodb) {
|
||||||
|
AutoServerManager.gameMongodb = gameMongodb;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AutoServerManager getInstance() {
|
private static String redisHost;
|
||||||
return AutoServerManager.Instance.instance;
|
public static String getRedisHost() {
|
||||||
|
return redisHost;
|
||||||
|
}
|
||||||
|
@Value("${spring.redis.host}")
|
||||||
|
public void setRedisHost(String redisHost) {
|
||||||
|
AutoServerManager.redisHost = redisHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String redisPwd;
|
||||||
|
public static String getRedisPwd() {
|
||||||
|
return redisPwd;
|
||||||
|
}
|
||||||
|
@Value("${spring.redis.password}")
|
||||||
|
public void setRedisPwd(String redisPwd) {
|
||||||
|
AutoServerManager.redisPwd = redisPwd;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long date = 0;
|
private static long date = 0;
|
||||||
|
|
@ -47,11 +71,6 @@ public class AutoServerManager {
|
||||||
public static final String REGISTER = "1";
|
public static final String REGISTER = "1";
|
||||||
public static final String AUTOTIME = "2";
|
public static final String AUTOTIME = "2";
|
||||||
|
|
||||||
@Resource
|
|
||||||
private ServerInfoDao serverInfoDao;
|
|
||||||
@Resource
|
|
||||||
private DingTalkLogic dingTalkLogic;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否开启自动开服功能
|
* 是否开启自动开服功能
|
||||||
*
|
*
|
||||||
|
|
@ -62,6 +81,12 @@ public class AutoServerManager {
|
||||||
return autoServerSetting != null && "1".equals(autoServerSetting.getState());
|
return autoServerSetting != null && "1".equals(autoServerSetting.getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取下一个服务器信息
|
||||||
|
* @param infoList
|
||||||
|
* @param num
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
private static ServerInfo getServerIndex(List<ServerInfo> infoList, int num){
|
private static ServerInfo getServerIndex(List<ServerInfo> infoList, int num){
|
||||||
ServerInfo info = null;
|
ServerInfo info = null;
|
||||||
try {
|
try {
|
||||||
|
|
@ -73,7 +98,7 @@ public class AutoServerManager {
|
||||||
/**
|
/**
|
||||||
* 开服
|
* 开服
|
||||||
*/
|
*/
|
||||||
void startServer(){
|
public static void startServer(){
|
||||||
try {
|
try {
|
||||||
if (isOpen()) {
|
if (isOpen()) {
|
||||||
// 当前时间
|
// 当前时间
|
||||||
|
|
@ -135,9 +160,9 @@ public class AutoServerManager {
|
||||||
* @param newServer
|
* @param newServer
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private void startServers(ServerInfo oldServer, ServerInfo newServer) throws Exception {
|
private static void startServers(ServerInfo oldServer, ServerInfo newServer) throws Exception {
|
||||||
// 停服脚本
|
// 停服脚本
|
||||||
AutoServerManager.getInstance().delUser(newServer);
|
delUser(newServer);
|
||||||
// 间隔30秒再获取开服数据
|
// 间隔30秒再获取开服数据
|
||||||
Thread.sleep(DateUtil.ONE_SECOND * 30);
|
Thread.sleep(DateUtil.ONE_SECOND * 30);
|
||||||
// 验证
|
// 验证
|
||||||
|
|
@ -156,7 +181,7 @@ public class AutoServerManager {
|
||||||
/**
|
/**
|
||||||
* 验证开服状态
|
* 验证开服状态
|
||||||
*/
|
*/
|
||||||
private boolean verifyServerStatus(ServerInfo serverInfo) {
|
private static boolean verifyServerStatus(ServerInfo serverInfo) {
|
||||||
String serverId = serverInfo.getServer_id();
|
String serverId = serverInfo.getServer_id();
|
||||||
// 错误信息
|
// 错误信息
|
||||||
String cont;
|
String cont;
|
||||||
|
|
@ -171,7 +196,7 @@ public class AutoServerManager {
|
||||||
if (sameDay){
|
if (sameDay){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
cont = "服务器验证开服时间错误:服务器信息:{"+serverTime.toString()+"}";
|
cont = "服务器验证开服时间错误:服务器信息:{"+ serverTime +"}";
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
cont = "服务器验证状态异常:{"+e.getMessage()+"}";
|
cont = "服务器验证状态异常:{"+e.getMessage()+"}";
|
||||||
|
|
@ -190,7 +215,7 @@ public class AutoServerManager {
|
||||||
* @param status
|
* @param status
|
||||||
* @param news
|
* @param news
|
||||||
*/
|
*/
|
||||||
private void updateServer(ServerInfo serverInfo, int status, int news, String serverId) throws Exception {
|
private static void updateServer(ServerInfo serverInfo, int status, int news, String serverId) throws Exception {
|
||||||
if (serverInfo == null) {
|
if (serverInfo == null) {
|
||||||
LOGGER.error("自动开服,服务器不存在:{}", serverId);
|
LOGGER.error("自动开服,服务器不存在:{}", serverId);
|
||||||
return;
|
return;
|
||||||
|
|
@ -204,11 +229,11 @@ public class AutoServerManager {
|
||||||
* 手动开服
|
* 手动开服
|
||||||
* @param vo
|
* @param vo
|
||||||
*/
|
*/
|
||||||
public void manualStartServer(ServerInfoVo vo){
|
public static void manualStartServer(ServerInfoVo vo){
|
||||||
try {
|
try {
|
||||||
ServerInfo serverInfo = serverInfoDao.getServerInfo(vo.getServer_id());
|
ServerInfo serverInfo = serverInfoDao.getServerInfo(vo.getServer_id());
|
||||||
// 停服脚本
|
// 停服脚本
|
||||||
AutoServerManager.getInstance().delUser(serverInfo);
|
delUser(serverInfo);
|
||||||
// 间隔30秒再获取开服数据
|
// 间隔30秒再获取开服数据
|
||||||
Thread.sleep(DateUtil.ONE_SECOND * 10);
|
Thread.sleep(DateUtil.ONE_SECOND * 10);
|
||||||
// 验证
|
// 验证
|
||||||
|
|
@ -229,15 +254,15 @@ public class AutoServerManager {
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public int rebootServer(String serverId) throws Exception {
|
public static int rebootServer(String serverId) throws Exception {
|
||||||
String path = "/data/jieling/reboot_core.sh";
|
String path = "/conf/script/reboot_core.sh";
|
||||||
|
|
||||||
ServerInfo serverInfo = serverInfoDao.getServerInfo(serverId);
|
ServerInfo serverInfo = serverInfoDao.getServerInfo(serverId);
|
||||||
if (serverInfo == null){
|
if (serverInfo == null){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
String command = "sh " + path + " " + serverInfo.getIp() + " " + serverInfo.getCoreName();
|
String command = "bash " + path + " " + serverInfo.getIp() + " " + serverInfo.getCoreName();
|
||||||
LOGGER.info("重启命令:{}", command);
|
LOGGER.info("重启命令:{}", command);
|
||||||
|
|
||||||
Process exec = null;
|
Process exec = null;
|
||||||
|
|
@ -264,17 +289,20 @@ public class AutoServerManager {
|
||||||
* @param serverInfo
|
* @param serverInfo
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private void delUser(ServerInfo serverInfo) {
|
private static void delUser(ServerInfo serverInfo) {
|
||||||
String path = "/data/jieling/deluser.sh";
|
String path = "conf/script/deluser.sh";
|
||||||
|
|
||||||
if (serverInfo.getIp() == null || "".equals(serverInfo.getIp())
|
if (serverInfo.getIp() == null || "".equals(serverInfo.getIp())
|
||||||
|| serverInfo.getServer_id() == null || "".equals(serverInfo.getServer_id())
|
|| serverInfo.getServer_id() == null || "".equals(serverInfo.getServer_id())
|
||||||
|| serverInfo.getCoreName() == null || "".equals(serverInfo.getCoreName())) {
|
|| serverInfo.getCoreName() == null || "".equals(serverInfo.getCoreName())) {
|
||||||
LOGGER.error("删除操作参数不全,执行失败:参数:{}", serverInfo.toString());
|
LOGGER.error("删除操作参数不全,执行失败:参数:{}", serverInfo);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String command = "sh " + path + " 500 " + serverInfo.getIp() + " " + serverInfo.getServer_id() + " " + serverInfo.getCoreName();
|
String space = " ";
|
||||||
|
|
||||||
|
String command = "bash " + path + serverInfo.getIp() + space + serverInfo.getServer_id() + space + serverInfo.getCoreName()
|
||||||
|
+ space + getGameMongodb() + space + getRedisHost() + space + getRedisPwd();
|
||||||
LOGGER.info("清库命令:{}", command);
|
LOGGER.info("清库命令:{}", command);
|
||||||
|
|
||||||
Process exec = null;
|
Process exec = null;
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,7 @@ public class MinuteTask implements Runnable {
|
||||||
|
|
||||||
public void setsHotFixManager(SHotFixManager sHotFixManager) {
|
public void setsHotFixManager(SHotFixManager sHotFixManager) {
|
||||||
this.sHotFixManager = sHotFixManager;
|
this.sHotFixManager = sHotFixManager;
|
||||||
}
|
};
|
||||||
|
|
||||||
@Resource
|
|
||||||
private AutoServerManager autoServer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 需要注意,这里面运行的方法需要自行在方法体内添加try-catch,防止报错
|
* 需要注意,这里面运行的方法需要自行在方法体内添加try-catch,防止报错
|
||||||
|
|
@ -34,7 +31,7 @@ public class MinuteTask implements Runnable {
|
||||||
//邮件补发
|
//邮件补发
|
||||||
getsHotFixManager().updateTablesWithTableNames();
|
getsHotFixManager().updateTablesWithTableNames();
|
||||||
//自动开服
|
//自动开服
|
||||||
autoServer.startServer();
|
AutoServerManager.startServer();
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue