/** 开启world服务 */ public String startServer(BeanInterface beanInterface) throws Exception { System.out.println("开启world服务"); StringBuffer stringBuffer = new StringBuffer(); WorldServer worldServer = (WorldServer) beanInterface; if (worldServer.getIsDeploy() == CommanConstant.STATE_START) { int accountState = CacheService.getAccountServerById(worldServer.getAccountId()).getState(); if (accountState == CommanConstant.STATE_START) { String startResult = SshxcuteUtils.startEachServer(worldServer, Global.WORLD_PID_FILE); stringBuffer.append(startResult); } else { stringBuffer.append("ID为:" + worldServer.getAccountId() + "ACCOUNT服务未启动,请先启动ACCOUNT!"); } } else { stringBuffer.append("ID为:" + worldServer.getId() + "worldServer未部署"); } return stringBuffer.toString(); }
/** 根据worldIds获取所对应的ACCOUNT中未开启的accountId */ public StringBuilder getAccountState(String worldIds) { StringBuilder sb = new StringBuilder(); try { String[] worldIdArray = worldIds.split(","); for (int i = 0; i < worldIdArray.length; i++) { AccountServer accountServer = CacheService.getAccountServerById( CacheService.getWorldServerById(Integer.valueOf(worldIdArray[i])).getAccountId()); // 检测ACCOUNT服务是否开启 if (accountServer.getState() == CommanConstant.STATE_STOP) { sb.append(accountServer.getId()).append(","); } } } catch (Exception e) { sb.append(e.getMessage()); e.printStackTrace(); } return sb; }