整理启动逻辑

This commit is contained in:
luying
2022-09-15 18:00:10 +08:00
parent d7d0216ad6
commit a592de3d17
5 changed files with 187 additions and 169 deletions
+25 -25
View File
@@ -30,6 +30,7 @@ import { resResult, genCode } from './app/pubUtils/util';
import { errlogger, infologger, loadLogger } from './app/util/logger';
import { connectThinkingData, getTire } from './app/services/sdkService';
import { loadGmDb } from './app/db';
import { loadActivities } from './app/services/activity/activityRemoteService';
const filePath = (_pinus as any).FILEPATH;
filePath.MASTER = '/config/master';
@@ -143,26 +144,6 @@ app.configure(ALL_ENVS, 'gm', function () {
app.filter(tokenFilter(app));
});
app.configure(ALL_ENVS, 'systimer', function () {
app.event.on('start_all', async (servers) => {
redisService.redisSubScribe();
await redisService.initAllRank();
await timeTaskService.init();
});
});
app.configure(ALL_ENVS, 'chat', function() {
app.event.on('start_all', () => {
getTire();
});
});
app.configure(ALL_ENVS, 'activity', function () {
app.event.on('start_all', () => {
app.rpc.activity.activityRemote.loadActivities.toServer(app.getServerId());
});
});
function errorHandler(err: Error, msg: any, resp: any,
session: FrontendOrBackendSession, cb: HandlerCallback) {
@@ -192,6 +173,30 @@ export function globalErrorHandler(err: Error, msg: any, resp: any,
async function treatStartLogic(app: _pinus.Application) {
await connectDb(app);
console.log('treatStartLogic', app.getServerType());
if(app.getServerType() == 'systimer') {
redisService.redisSubScribe();
timeTaskService.init();
}
if(app.getServerType() == 'chat') {
getTire();
}
if(app.getServerType() == 'activity') {
loadActivities();
}
treatStartMainten(app);
if(app.isMaster()) {
redisService.initAllRank();
redisService.readDataBase();
redisService.clearComBtlQueue();
redisService.clearChannelServers();
updateTeamStatus(COM_TEAM_STATUS.DEFAULT, COM_TEAM_STATUS.LOOSE);
updateTeamStatus(COM_TEAM_STATUS.FIGHTING, COM_TEAM_STATUS.LOOSE);
}
}
async function treatStartMainten(app: _pinus.Application) {
if(app.getServerType() == 'systimer') {
// 维护信息
await timeTaskService.initMaintenance();
@@ -286,11 +291,6 @@ if (app.isMaster()) {
app.event.on('start_all', () => {
// 全部服务器启动完毕后初始化 redis 数据
redisService.checkConnectors();
redisService.readDataBase();
redisService.clearComBtlQueue();
redisService.clearChannelServers();
updateTeamStatus(COM_TEAM_STATUS.DEFAULT, COM_TEAM_STATUS.LOOSE);
updateTeamStatus(COM_TEAM_STATUS.FIGHTING, COM_TEAM_STATUS.LOOSE);
});
}