后台:内存快照
This commit is contained in:
@@ -8,6 +8,7 @@ import { ActivityInRemote } from '../../../domain/activityField/activityField';
|
||||
import { errlogger } from '../../../util/logger';
|
||||
import { ActivityGroupModel } from '../../../db/ActivityGroup';
|
||||
import { deleteActivities, loadActivities, saveActivitiesToGroup, updateActivities, _getActivityById, _getActivitiesByType, _getActivities, _getActivitiesByServerId } from '../../../services/activity/activityRemoteService';
|
||||
import { saveActivityMemory } from '../../../services/log/memoryLogService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -139,4 +140,12 @@ export class ActivityRemote {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public saveActivityMemory() {
|
||||
try {
|
||||
return saveActivityMemory();
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { Application, ChannelService, FrontendSession, RemoterClass, HandlerServ
|
||||
import { PVPConfigModel, PVPConfigType } from '../../../db/SystemConfig';
|
||||
import { reloadResources } from '../../../pubUtils/data';
|
||||
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
|
||||
import { savePvpSeasonMemory } from '../../../services/log/memoryLogService';
|
||||
import { taflush } from '../../../services/sdkService';
|
||||
import { errlogger } from '../../../util/logger';
|
||||
|
||||
@@ -140,4 +141,12 @@ export class BattleRemote {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public savePvpSeasonMemory() {
|
||||
try {
|
||||
return savePvpSeasonMemory();
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import { STATUS } from '../../../consts';
|
||||
import { handleComBtlProgress, _addToSearchingTeams } from '../../../services/comBattleService';
|
||||
import { MemComBtlTeam } from '../../../domain/battleField/ComBattleTeamField';
|
||||
import { errlogger } from '../../../util/logger';
|
||||
import { saveComBattleMemory } from '../../../services/log/memoryLogService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -44,4 +45,11 @@ export class ComBattleRemote {
|
||||
}
|
||||
}
|
||||
|
||||
public saveComBattleMemory() {
|
||||
try {
|
||||
return saveComBattleMemory();
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import { getServerMainten, setServerMainten, stopServerMainten } from '../../../
|
||||
import { taflush } from '../../../services/sdkService';
|
||||
import { errlogger } from '../../../util/logger';
|
||||
import { setWeek } from '../../../pubUtils/timeUtil';
|
||||
import { savePvpSeasonMemory } from '../../../services/log/memoryLogService';
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
return new ConnectorRemote(app);
|
||||
@@ -171,4 +172,12 @@ export class ConnectorRemote {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public savePvpSeasonMemory() {
|
||||
try {
|
||||
return savePvpSeasonMemory();
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Application, BackendSession, pinus } from 'pinus';
|
||||
import { getRandSingleEelm, resResult } from '../../../pubUtils/util';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { GMMailModel, GMMailType } from '../../../db/GMMail';
|
||||
import { ACTIVITY_TYPE, GM_MAIL_STATUS, GM_MAIL_TYPE, MAIL_TIME_TYPE, PUSH_ROUTE, SURVEY_SELECT } from '../../../consts';
|
||||
import { ACTIVITY_TYPE, GM_MAIL_STATUS, GM_MAIL_TYPE, MAIL_TIME_TYPE, MEMORY_LOG_TYPE, PUSH_ROUTE, SURVEY_SELECT } from '../../../consts';
|
||||
import { ActivityModel } from '../../../db/Activity';
|
||||
import { ActivityGroupModel } from '../../../db/ActivityGroup';
|
||||
import { ActivityGroupTypeModel } from '../../../db/ActivityGroupType';
|
||||
@@ -16,6 +16,8 @@ import { SurveyModel, SurveyUpdate } from '../../../db/Survery';
|
||||
import { getSurvey } from '../../../services/gmService';
|
||||
import { sendMessageToAllWithSuc } from '../../../services/pushService';
|
||||
import { sendMailByContent, sendMailsByGmMail } from '../../../services/mailService';
|
||||
import { saveMemory } from '../../../services/log/memoryLogService';
|
||||
|
||||
let timer: NodeJS.Timer;
|
||||
export default function (app: Application) {
|
||||
return new GmHandler(app);
|
||||
@@ -276,4 +278,10 @@ export class GmHandler {
|
||||
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
async saveMemoryLog(msg: { memoryLogType: MEMORY_LOG_TYPE }, session: BackendSession) {
|
||||
const { memoryLogType } = msg;
|
||||
await saveMemory(memoryLogType);
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import { addItems } from '../../../services/role/rewardService';
|
||||
import { RewardInter } from '../../../pubUtils/interface';
|
||||
import { gameData, getExpByLv, getHeroExpByLv, getHeroLvByExp, getLvByExp } from '../../../pubUtils/data';
|
||||
import { RoleModel, RoleType, WarStar } from '../../../db/Role';
|
||||
import { BLOCK_TYPE, DEFAULT_HEROES, GUILD_AUTH, GUILD_DISMISS_WAY, GUILD_JOB, GUILD_MASTER_CHANGE_WAY, GUILD_STATUS, GUILD_STRUCTURE, HERO_SYSTEM_TYPE, ITEM_CHANGE_REASON, MAIL_TYPE, PUSH_ROUTE, REDIS_KEY, TA_EVENT, WAR_TYPE } from '../../../consts';
|
||||
import { BLOCK_TYPE, DEFAULT_HEROES, GUILD_AUTH, GUILD_DISMISS_WAY, GUILD_JOB, GUILD_MASTER_CHANGE_WAY, GUILD_STATUS, GUILD_STRUCTURE, HERO_SYSTEM_TYPE, ITEM_CHANGE_REASON, MAIL_TYPE, MEMORY_LOG_TYPE, PUSH_ROUTE, REDIS_KEY, TA_EVENT, WAR_TYPE } from '../../../consts';
|
||||
import { GuildFormParam, SetHeroParam } from '../../../domain/backEndField/params';
|
||||
import { GuildModel, GuildUpdateParam } from '../../../db/Guild';
|
||||
import { Rank } from '../../../services/rankService';
|
||||
|
||||
@@ -5,6 +5,7 @@ import { setWeek } from '../../../pubUtils/timeUtil';
|
||||
import { sendUngotDividend } from '../../../services/auctionService';
|
||||
import { errlogger } from '../../../util/logger';
|
||||
import { GUILD_ACTIVITY_TYPE } from '../../../consts';
|
||||
import { saveGuildActivityIndexMemory } from '../../../services/log/memoryLogService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -213,4 +214,12 @@ export class GuildActivityRemote {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public saveGuildActivityIndexMemory() {
|
||||
try {
|
||||
return saveGuildActivityIndexMemory();
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
114
game-server/app/services/log/memoryLogService.ts
Normal file
114
game-server/app/services/log/memoryLogService.ts
Normal file
@@ -0,0 +1,114 @@
|
||||
import { pinus } from "pinus";
|
||||
import { GUILD_ACTIVITY_TYPE, MEMORY_LOG_TYPE } from "../../consts";
|
||||
import { ActivityInRemote } from "../../domain/activityField/activityField";
|
||||
import { MemComBtlTeam } from "../../domain/battleField/ComBattleTeamField";
|
||||
import { saveMemoryLog, saveMemoryLogs } from "../../pubUtils/logUtil";
|
||||
import { getGAIndexInPinus } from "../guildActivity/guildActivityService";
|
||||
|
||||
// 将内存打印下来
|
||||
export async function saveMemory(type: MEMORY_LOG_TYPE) {
|
||||
switch (type) {
|
||||
case MEMORY_LOG_TYPE.ACTIVITY:
|
||||
await _saveActivityMemory();
|
||||
break;
|
||||
case MEMORY_LOG_TYPE.PVP_SEASON:
|
||||
await _savePvpSeasonMemory();
|
||||
break;
|
||||
case MEMORY_LOG_TYPE.GA_INDEX:
|
||||
await _saveGuildActivityIndexMemory();
|
||||
break;
|
||||
case MEMORY_LOG_TYPE.COMBATTLE:
|
||||
await _saveComBattleMemory();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
async function _saveActivityMemory() {
|
||||
await pinus.app.rpc.activity.activityRemote.saveActivityMemory.broadcast();
|
||||
}
|
||||
|
||||
// activity服
|
||||
export async function saveActivityMemory() {
|
||||
await saveMemoryLogs(pinus.app.getServerId(), [
|
||||
{ memoryLogField: 'activities', memoryData: treatActivities(pinus.app.get('activities')) },
|
||||
{ memoryLogField: 'activityByServer', memoryData: treatActivityByServer(pinus.app.get('activityByServer')) },
|
||||
{ memoryLogField: 'activityByType', memoryData: treatActivityType(pinus.app.get('activityByType')) },
|
||||
{ memoryLogField: 'groupToServer', memoryData: treatGroupToServer(pinus.app.get('groupToServer')) },
|
||||
]);
|
||||
}
|
||||
|
||||
function treatActivities(activities: Map<number, ActivityInRemote> = new Map()) {
|
||||
let result: ActivityInRemote[] = [];
|
||||
for(let [_, activity] of activities) {
|
||||
result.push(activity);
|
||||
}
|
||||
return JSON.stringify(result);
|
||||
}
|
||||
|
||||
function treatActivityByServer(activityByServer: Map<number, number[]> = new Map()) {
|
||||
let result: { serverId: number, activityIds: number[] }[] = [];
|
||||
for(let [ serverId, activityIds ] of activityByServer) {
|
||||
result.push({ serverId, activityIds });
|
||||
}
|
||||
return JSON.stringify(result);
|
||||
}
|
||||
|
||||
function treatActivityType(activityByType: Map<number, Map<number, number[]>> = new Map()) {
|
||||
let result: { serverId: number, type: number, activityIds: number[] }[] = [];
|
||||
for(let [ serverId, typeToActivity ] of activityByType) {
|
||||
for(let [ type, activityIds ] of typeToActivity) {
|
||||
result.push({ serverId, type, activityIds });
|
||||
}
|
||||
}
|
||||
return JSON.stringify(result);
|
||||
}
|
||||
|
||||
function treatGroupToServer(groupToServer: Map<number, number[]> = new Map()) {
|
||||
let result: { groupId: number, serverIds: number[] }[] = [];
|
||||
for(let [groupId, serverIds] of groupToServer) {
|
||||
result.push({ groupId, serverIds });
|
||||
}
|
||||
return JSON.stringify(result);
|
||||
}
|
||||
|
||||
async function _savePvpSeasonMemory() {
|
||||
await pinus.app.rpc.battle.battleRemote.savePvpSeasonMemory.broadcast();
|
||||
await pinus.app.rpc.connector.connectorRemote.savePvpSeasonMemory.broadcast();
|
||||
}
|
||||
|
||||
export async function savePvpSeasonMemory() {
|
||||
let data = {
|
||||
pvpSeasonNum: pinus.app.get('pvpSeasonNum'),
|
||||
pvpSeasonEndTime: pinus.app.get('pvpSeasonEndTime')
|
||||
}
|
||||
await saveMemoryLog(pinus.app.getServerId(), 'pvpSeason', JSON.stringify(data));
|
||||
}
|
||||
|
||||
async function _saveGuildActivityIndexMemory() {
|
||||
await pinus.app.rpc.guild.guildActivityRemote.saveGuildActivityIndexMemory.broadcast();
|
||||
}
|
||||
|
||||
export async function saveGuildActivityIndexMemory() {
|
||||
let data = {
|
||||
gateActivity: getGAIndexInPinus(GUILD_ACTIVITY_TYPE.GATE_ACTIVITY),
|
||||
cityActivity: getGAIndexInPinus(GUILD_ACTIVITY_TYPE.CITY_ACTIVITY),
|
||||
raceActivity: getGAIndexInPinus(GUILD_ACTIVITY_TYPE.RACE_ACTIVITY),
|
||||
}
|
||||
await saveMemoryLog(pinus.app.getServerId(), 'gaIndex', JSON.stringify(data));
|
||||
}
|
||||
|
||||
async function _saveComBattleMemory() {
|
||||
await pinus.app.rpc.battle.comBattleRemote.saveComBattleMemory.broadcast();
|
||||
}
|
||||
|
||||
export async function saveComBattleMemory() {
|
||||
await saveMemoryLog(pinus.app.getServerId(), 'comBattle', treatTeamMap(pinus.app.get('teamMap')));
|
||||
}
|
||||
|
||||
function treatTeamMap(teamMap: Map<string, MemComBtlTeam> = new Map()) {
|
||||
let result: MemComBtlTeam[] = [];
|
||||
for(let [_teamCode, team] of teamMap) {
|
||||
result.push(team);
|
||||
}
|
||||
return JSON.stringify(result);
|
||||
}
|
||||
Reference in New Issue
Block a user