4936 【工具】没有绿的异常报错增加发送运维邮件通知
| | |
| | | callFunc(orderId, cmdDict)
|
| | |
|
| | | except BaseException:
|
| | | GameWorld.Log('GM命令错误 - > %s'%(traceback.format_exc()))
|
| | |
|
| | | GMCommon.GMCommandResult(orderId, gmCmdDict, GMCommon.Def_GMGSEntranceFail)
|
| | | if GameWorld.GetGameWorld().GetDebugLevel():
|
| | | raise BaseException(str(traceback.format_exc()))
|
| | | GameWorld.RaiseException('GM命令错误\r\n%s'%(traceback.format_exc()))
|
| | | return
|
| | |
|
| | | return
|
| | |
| | |
|
| | | return inputText
|
| | |
|
| | | def RaiseException(errorMsg, playerID=0):
|
| | | ## 处理抛出异常信息,debug下直接抛出异常报错信息,否则发送运维邮件提醒
|
| | | ErrLog(errorMsg, playerID)
|
| | | if GetGameWorld().GetDebugLevel():
|
| | | raise Exception(errorMsg)
|
| | | else:
|
| | | SendGameError("GameServerRaiseException", errorMsg)
|
| | | return
|
| | |
|
| | | # 向运维发送邮件,用于需要紧急处理的信息
|
| | | # 此处不包含服务器报错的汇报
|
| | | def SendGameStateMail(msgInfo):
|
| | | # 使用方式 向OpenStateUrl 发送Type为GameWarning,那么就会收到一封游戏内容警告邮件,信息为MsgInfo
|
| | | def SendGameError(errType, msgInfo=""):
|
| | | ''' 向运维发送邮件,用于需要紧急处理的信息
|
| | | @param errType: 错误类型,自定义即可
|
| | | @param msgInfo: 错误信息,可选
|
| | | '''
|
| | | getUrl = ReadChConfig.GetPyMongoConfig("EventReport", "OpenStateUrl")
|
| | | groupID = ReadChConfig.GetPyMongoConfig("platform", "GroupID")
|
| | | userDBName = ReadChConfig.GetPyMongoConfig("connect", "USER_DB_NAME")
|
| | | getUrl = getUrl + "?Type=GameWarning&groupID=%s&userDBName=%s&MsgInfo=%s"%(groupID, userDBName, urllib.quote_plus(msgInfo))
|
| | | |
| | | getUrl = getUrl + "?Type=%s&groupID=%s&userDBName=%s"%(errType, groupID, userDBName)
|
| | | if msgInfo:
|
| | | getUrl = getUrl + "&MsgInfo=%s" % urllib.quote_plus(msgInfo)
|
| | | GetGameWorld().EventReport_EventReport("", "", "", "", 0, getUrl)
|
| | | |
| | | return
|
| | |
| | | GameWorld.ErrLog("没有该信息类型逻辑处理!")
|
| | |
|
| | | except:
|
| | | GameWorld.ErrLog("OnCrossServerReceiveMsg: %s" % (traceback.format_exc()))
|
| | | if GameWorld.GetGameWorld().GetDebugLevel():
|
| | | raise BaseException(str(traceback.format_exc()))
|
| | | GameWorld.RaiseException("跨服服务器接收信息处理报错 \r\n%s" % str(traceback.format_exc()))
|
| | | return
|
| | |
|
| | | def ClientServerMsg_ServerInitOK(serverGroupID, tick):
|
| | |
| | | GameWorld.ErrLog("没有该信息类型逻辑处理!")
|
| | |
|
| | | except:
|
| | | GameWorld.ErrLog("OnClientServerReceiveMsg: %s" % (traceback.format_exc()))
|
| | | if GameWorld.GetGameWorld().GetDebugLevel():
|
| | | raise BaseException(str(traceback.format_exc()))
|
| | | |
| | | GameWorld.RaiseException("子服服务器接收信息处理报错\r\n%s" % str(traceback.format_exc()))
|
| | | return
|
| | |
|
| | | def MapServer_ClientServerReceiveMsg(msgType, msgData):
|
| | |
| | | if mapServerPack.GetState() not in [0,1,2,3] and curMap.GetState() != mapServerPack.GetState():
|
| | | # 记录服务器是否正常开启完毕, 避免重复发送
|
| | | GameWorld.DebugLog("MapServer_RunningStateRefresh--_%s"%([mapServerPack.GetState(), curMap.GetState(), mapServerPack.GetMapID(), curMap.GetID()]))
|
| | | SendGameError("MapError")
|
| | | GameWorld.SendGameError("MapError")
|
| | |
|
| | | curMap.SetState(mapServerPack.GetState())
|
| | | curMap.SetRefreshTick(tick)
|
| | |
|
| | | return
|
| | |
|
| | |
|
| | | def SendGameError(state):
|
| | | getUrl = ReadChConfig.GetPyMongoConfig("EventReport", "OpenStateUrl")
|
| | | groupID = ReadChConfig.GetPyMongoConfig("platform", "GroupID")
|
| | | userDBName = ReadChConfig.GetPyMongoConfig("connect", "USER_DB_NAME")
|
| | | getUrl = getUrl + "?Type=%s&groupID=%s&userDBName=%s"%(state, groupID, userDBName)
|
| | | GameWorld.GetGameWorld().EventReport_EventReport("", "", "", "", 0, getUrl)
|
| | |
|
| | | ## 刷新地图服务器状态, 如果1分钟没有状态回报, 刷新为消失状态
|
| | | # @param tick 当前时间
|
| | |
| | | curMap.SetState(IPY_GameServer.mssNone)
|
| | | if not isSendMapClose:
|
| | | # 避免多地图发送过多邮件, 如关服的时候
|
| | | SendGameError("MapDisconnect") # 状态报告
|
| | | GameWorld.SendGameError("MapDisconnect") # 状态报告
|
| | | isSendMapClose = True
|
| | |
|
| | | return
|
| | |
| | | def ChangeGameServerState(state):
|
| | | # 只接收大于等于mssPyError
|
| | | GameWorld.DebugLog("ChangeGameServerState:%s"%state)
|
| | | SendGameError("GameServerError")
|
| | | GameWorld.SendGameError("GameServerError")
|
| | |
|
| | | |
| | |
| | | curPackHeadRegDict["CallFunc"](index, curPackData, tick)
|
| | |
|
| | | except Exception:
|
| | | Log("python自定义封包解析失败~~~~~\r\n%s" % traceback.format_exc())
|
| | | if GameWorld.GetGameWorld().GetDebugLevel():
|
| | | raise Exception("python自定义封包解析失败~~~~~\r\n%s" % traceback.format_exc())
|
| | | GameWorld.RaiseException("python自定义封包解析失败\r\n%s" % traceback.format_exc())
|
| | | return
|
| | |
|
| | |
|
| | |
| | | curPackHeadRegDict["CallFunc"](routeIndex, mapID, curPackData, tick)
|
| | | #Log("RecvMapPyPack: CallFunc curPackHead = %s"%curPackHead)
|
| | | except Exception:
|
| | | Log("RecvMapPyPack python自定义封包解析失败~~~~~\r\n%s" % traceback.format_exc())
|
| | | if GameWorld.GetGameWorld().GetDebugLevel():
|
| | | raise Exception("RecGamePyPack python自定义封包解析失败~~~~~\r\n%s" % traceback.format_exc())
|
| | | GameWorld.RaiseException("RecvMapPyPack python自定义封包解析失败\r\n%s" % traceback.format_exc())
|
| | | return
|
| | |
|
| | | #-------------------------------------------------------------------------------
|
| | |
| | | except:
|
| | | curPlayer.Kick(IPY_PlayerDefine.disWaitForPlayerLoinError)
|
| | | import traceback
|
| | | GameWorld.ErrLog("玩家上线逻辑错误~~~~~\r\n%s" % traceback.format_exc())
|
| | | if GameWorld.GetGameWorld().GetDebugLevel():
|
| | | raise Exception("玩家上线逻辑错误~~~~\r\n%s" % traceback.format_exc())
|
| | | GameWorld.RaiseException("玩家上线逻辑错误\r\n%s" % traceback.format_exc())
|
| | | return
|
| | |
|
| | | #---------------------------------------------------------------------
|
| | |
| | | __Func_PlayerDisconnect(curPlayer, tick)
|
| | | except:
|
| | | import traceback
|
| | | GameWorld.ErrLog("玩家下线逻辑错误~~~~~\r\n%s" % traceback.format_exc())
|
| | | if GameWorld.GetGameWorld().GetDebugLevel():
|
| | | raise Exception("玩家下线逻辑错误~~~~\r\n%s" % traceback.format_exc())
|
| | | GameWorld.RaiseException("玩家下线逻辑错误\r\n%s" % traceback.format_exc())
|
| | | #调用底层下线
|
| | | curPlayer.DoDisconnect()
|
| | | return
|
| | |
| | | SendEventPack("CTGError", dataDict, curPlayer)
|
| | | GameWorld.ErrLog("%s. %s" % (errorInfo, addDict), curPlayer.GetPlayerID())
|
| | |
|
| | | GameWorld.SendGameStateMail("CTGError:%s - %s"%(errorInfo, dataDict))
|
| | | GameWorld.SendGameError("GameWarning", "CTGError:%s - %s"%(errorInfo, dataDict))
|
| | | return
|
| | |
|
| | | def DR_CTGOK(curPlayer, addDict):
|
| | |
| | | curPlayer.DebugAnswer(text)
|
| | | return
|
| | |
|
| | | def RaiseException(errorMsg, playerID=0):
|
| | | ## 处理抛出异常信息,debug下直接抛出异常报错信息,否则发送运维邮件提醒
|
| | | ErrLog(errorMsg, playerID)
|
| | | if GetGameWorld().GetDebugLevel():
|
| | | raise Exception(errorMsg)
|
| | | else:
|
| | | SendGameError("MapServerRaiseException", errorMsg)
|
| | | return
|
| | |
|
| | | # 向运维发送邮件,用于需要紧急处理的信息
|
| | | # 此处不包含服务器报错的汇报
|
| | | def SendGameStateMail(msgInfo):
|
| | | # 使用方式 向OpenStateUrl 发送Type为GameWarning,那么就会收到一封游戏内容警告邮件,信息为MsgInfo
|
| | | def SendGameError(errType, msgInfo=""):
|
| | | ''' 向运维发送邮件,用于需要紧急处理的信息
|
| | | @param errType: 错误类型,自定义即可
|
| | | @param msgInfo: 错误信息,可选
|
| | | '''
|
| | | getUrl = ReadChConfig.GetPyMongoConfig("EventReport", "OpenStateUrl")
|
| | | groupID = ReadChConfig.GetPyMongoConfig("platform", "GroupID")
|
| | | userDBName = ReadChConfig.GetPyMongoConfig("connect", "USER_DB_NAME")
|
| | | getUrl = getUrl + "?Type=GameWarning&groupID=%s&userDBName=%s&MsgInfo=%s"%(groupID, userDBName, urllib.quote_plus(msgInfo))
|
| | | |
| | | getUrl = getUrl + "?Type=%s&groupID=%s&userDBName=%s&mapID=%s"%(errType, groupID, userDBName, GetMap().GetMapID())
|
| | | if msgInfo:
|
| | | getUrl = getUrl + "&MsgInfo=%s" % urllib.quote_plus(msgInfo)
|
| | | GetGameWorld().EventReport_EventReport("", "", "", "", 0, getUrl)
|
| | |
|
| | | return
|
| | |
|
| | |
| | | curPackHeadRegDict["CallFunc"](index, curPackData, tick)
|
| | |
|
| | | except Exception:
|
| | | Log("!!!python自定义封包解析失败~~~~~\r\n%s" % traceback.format_exc())
|
| | | if GameWorld.GetGameWorld().GetDebugLevel():
|
| | | raise Exception("python自定义封包解析失败~~~~~\r\n%s" % traceback.format_exc())
|
| | | GameWorld.RaiseException("!!!python自定义封包解析失败\r\n%s" % traceback.format_exc())
|
| | | return
|
| | |
|
| | |
|
| | |
| | | curPackHeadRegDict["CallFunc"](curPackData, tick)
|
| | | #Log("RecGamePyPack: curPackHead = %s"%curPackHead)
|
| | | except Exception:
|
| | | Log("RecGamePyPack python自定义封包解析失败~~~~~\r\n%s" % traceback.format_exc())
|
| | | if GameWorld.GetGameWorld().GetDebugLevel():
|
| | | raise Exception("RecGamePyPack python自定义封包解析失败~~~~~\r\n%s" % traceback.format_exc())
|
| | | GameWorld.RaiseException("RecGamePyPack python自定义封包解析失败\r\n%s" % traceback.format_exc())
|
| | | return
|
| | | #-------------------------------------------------------------------------------
|
| | | ##发送Map到GameServer的沟通包
|
| | |
| | | except:
|
| | | curPlayer.Kick(IPY_GameWorld.disWaitForPlayerLoinError)
|
| | | import traceback
|
| | | GameWorld.ErrLog("玩家上线逻辑错误~~~~~\r\n%s" % traceback.format_exc())
|
| | | if GameWorld.GetGameWorld().GetDebugLevel():
|
| | | raise Exception("玩家上线逻辑错误~~~~\r\n%s" % traceback.format_exc())
|
| | | GameWorld.RaiseException("玩家上线逻辑错误\r\n%s" % traceback.format_exc())
|
| | | return
|
| | |
|
| | |
|
| | |
| | | DoPlayerDisconnect(curPlayer, tick)
|
| | | except:
|
| | | import traceback
|
| | | GameWorld.ErrLog("玩家下线逻辑错误~~~~~\r\n%s" % traceback.format_exc())
|
| | | if GameWorld.GetGameWorld().GetDebugLevel():
|
| | | raise Exception("玩家下线逻辑错误~~~~~\r\n%s" % traceback.format_exc())
|
| | | GameWorld.RaiseException("玩家下线逻辑错误\r\n%s" % traceback.format_exc())
|
| | |
|
| | | #调用底层使玩家下线
|
| | | curPlayer.DoDisconnect(tick)
|
| | |
| | |
|
| | | except BaseException:
|
| | | errorMsg = str(traceback.format_exc())
|
| | | GameWorld.ErrLog('接收跨服变更玩家数据错误 - > %s' % errorMsg, curPlayer.GetPlayerID())
|
| | | if GameWorld.GetGameWorld().GetDebugLevel():
|
| | | raise Exception(errorMsg)
|
| | | |
| | | GameWorld.RaiseException('接收跨服变更玩家数据错误 \r\n%s' % errorMsg, curPlayer.GetPlayerID())
|
| | | return
|
| | |
|
| | | ## ----------------------------------------------------------------------------------------------
|
| | |
| | | except:
|
| | | curPlayer.Kick(IPY_GameWorld.disWaitForPlayerLoinError)
|
| | | import traceback
|
| | | GameWorld.ErrLog("玩家上线逻辑错误~~~~~\r\n%s" % traceback.format_exc())
|
| | | if GameWorld.GetGameWorld().GetDebugLevel():
|
| | | raise Exception("玩家上线逻辑错误~~~~\r\n%s" % traceback.format_exc())
|
| | | GameWorld.RaiseException("玩家上线逻辑错误\r\n%s" % traceback.format_exc())
|
| | | return
|
| | |
|
| | | #--------------------------------------------------------
|
| | |
| | | dataDict.get("userDBName", 0),
|
| | | urllib.unquote_plus(dataDict.get("MsgInfo", 0)))
|
| | | SendEmail(ServerInfo)
|
| | | elif stateType in ["MapServerRaiseException", "GameServerRaiseException", "RaiseException"]:
|
| | | ServerInfo = "%s 抛出Try异常报错:服务器组:%s, dbname:%s, MapID:%s 异常信息:%s"%(
|
| | | stateType,
|
| | | dataDict.get("groupID", 0),
|
| | | dataDict.get("userDBName", 0),
|
| | | dataDict.get("mapID", 0),
|
| | | urllib.unquote_plus(dataDict.get("MsgInfo", 0)))
|
| | | SendEmail(ServerInfo)
|
| | | elif stateType == "QueryMapOK":
|
| | | if g_AllMapCnt == 0:
|
| | | if not os.path.exists(".\MapCount.txt"):
|
| | |
| | | sender = '2199274165@qq.com'
|
| | |
|
| | | # 这里可以填写需要接收汇报的邮件地址
|
| | | receivers = ['305670599@qq.com']#, '1142397645@qq.com'] |
| | | receivers = ['305670599@qq.com']#, '1142397645@qq.com', '305670599@qq.com', '995275190@qq.com'] |
| | |
|
| | | message = MIMEText('异常汇报:%s'%ServerInfo, 'plain', 'gbk')
|
| | | message['From'] = Header("游戏服务器异常汇报", 'gbk')
|