From 375d0bdab05c49aeac30b8b8e563383cf8598b18 Mon Sep 17 00:00:00 2001 From: liangtongchuan Date: Fri, 10 Sep 2021 18:43:56 +0800 Subject: [PATCH] =?UTF-8?q?redis=EF=BC=9A=E6=95=B0=E6=8D=AE=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E6=97=B6=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game-server/app.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/game-server/app.ts b/game-server/app.ts index b184fd3b8..4d506c8f9 100644 --- a/game-server/app.ts +++ b/game-server/app.ts @@ -162,15 +162,6 @@ function initRedis(app: _pinus.Application) { app.set('redis', redisClient); redLockService.initRedlock(redisClient); redlockCacheService.init(); - // TODO 重启 1 次只需要初始化 1 次,判断方法可以优化 - if (app.serverId === 'master-server-1') { - redisService.readDataBase(); - redisService.initAllRank(); - redisService.clearComBtlQueue(); - redisService.clearChannelServers(); - updateTeamStatus(COM_TEAM_STATUS.DEFAULT, COM_TEAM_STATUS.LOOSE); - updateTeamStatus(COM_TEAM_STATUS.FIGHTING, COM_TEAM_STATUS.LOOSE); - } } function setupRoutes(app: _pinus.Application) { @@ -223,6 +214,15 @@ if (app.isMaster()) { app.event.on('remove_servers', (server) => { redisService.removeConnectors(server); }) + app.event.on('start_all', (servers) => { + // 全部服务器启动完毕后初始化 redis 数据 + redisService.readDataBase(); + redisService.initAllRank(); + redisService.clearComBtlQueue(); + redisService.clearChannelServers(); + updateTeamStatus(COM_TEAM_STATUS.DEFAULT, COM_TEAM_STATUS.LOOSE); + updateTeamStatus(COM_TEAM_STATUS.FIGHTING, COM_TEAM_STATUS.LOOSE); + }); } // start app