维护:修改维护启动逻辑,扩展服也能正常获取
This commit is contained in:
@@ -8,7 +8,6 @@ import { gameData } from '../../../pubUtils/data';
|
||||
import { Maintenance, ServerlistModel, ServerlistUpdate } from '../../../db/Serverlist';
|
||||
import { nowSeconds } from '../../../pubUtils/timeUtil';
|
||||
import { createNewServer, sendOpenServerMail } from '../../../services/gmService';
|
||||
import { initAutoCreateServer, initMaintenance, stopMaintenance } from '../../../services/timeTaskService';
|
||||
import { isNumber } from 'util';
|
||||
import { MarqueeModel } from '../../../db/Marquee';
|
||||
let timer: NodeJS.Timer;
|
||||
|
||||
@@ -169,6 +169,7 @@ export function setServerMainten(serverIds: number[], startTime: number, endTime
|
||||
pinus.app.set('maintenServers', maintenServers);
|
||||
}
|
||||
|
||||
|
||||
export function stopServerMainten(serverIds: number[]) {
|
||||
let maintenServers = pinus.app.get('maintenServers')||new Map();
|
||||
for(let id of serverIds) {
|
||||
|
||||
@@ -13,7 +13,7 @@ import { sendEndMsgToAllServer, autoDeclare, sendGuildActivityStatus, setPreDayA
|
||||
import { sendUngotDividendJob, startGuildAuction, startWorldAuction, stopAuction } from './auctionService';
|
||||
import { DicGuildActivity } from '../pubUtils/dictionary/DicGuildActivity';
|
||||
import { dispatch } from '../pubUtils/dispatcher';
|
||||
import { createNewServer, initMarquee } from './gmService';
|
||||
import { createNewServer, initMarquee, setServerMainten } from './gmService';
|
||||
import moment = require('moment');
|
||||
import { CounterModel } from '../db/Counter';
|
||||
import { reportOneOnline } from './authenticateService';
|
||||
@@ -91,9 +91,6 @@ export async function init() {
|
||||
// 跑马灯
|
||||
await initMarquee();
|
||||
|
||||
// 维护信息
|
||||
await initMaintenance();
|
||||
|
||||
// 自动开服
|
||||
await initAutoCreateServer();
|
||||
|
||||
@@ -516,7 +513,7 @@ async function pushMailSchedule(time: number) {
|
||||
|
||||
// —————————————— 维护 —————————————— //
|
||||
let maintenInfos = new Map<string, { servers: ServerlistType[], maintenance: Maintenance }>(); // batchCode => {servers, maintenance}
|
||||
export async function initMaintenance(servers?: ServerlistType[]) {
|
||||
export async function initMaintenance(servers?: ServerlistType[], fromApp = false) {
|
||||
if(!servers) servers = await ServerlistModel.findByEnv(pinus.app.get('env'));
|
||||
|
||||
for(let server of servers) {
|
||||
@@ -529,12 +526,23 @@ export async function initMaintenance(servers?: ServerlistType[]) {
|
||||
}
|
||||
}
|
||||
for(let [batchCode] of maintenInfos) {
|
||||
await setMaintenance(batchCode);
|
||||
await setMaintenance(batchCode, fromApp);
|
||||
}
|
||||
}
|
||||
|
||||
export async function initMaintenanaceInOtherServers() {
|
||||
const servers = await ServerlistModel.findByEnv(pinus.app.get('env'));
|
||||
|
||||
for(let server of servers) {
|
||||
let { id, maintenance } = server;
|
||||
if(maintenance && maintenance.isOpen) {
|
||||
setServerMainten([id], maintenance.startTime, maintenance.endTime)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 设置维护
|
||||
async function setMaintenance(batchCode: string) {
|
||||
async function setMaintenance(batchCode: string, fromApp: boolean) {
|
||||
let { maintenance } = maintenInfos.get(batchCode);
|
||||
|
||||
console.log('***** maintenance', maintenance);
|
||||
@@ -557,8 +565,7 @@ async function setMaintenance(batchCode: string) {
|
||||
console.log('******* setMaintenance', now, now < maintenance.endTime, now > maintenance.startTime)
|
||||
if(now < maintenance.endTime) {
|
||||
if(now > maintenance.startTime) {
|
||||
console.log('*******')
|
||||
await startMaintenanceSchedule(batchCode);
|
||||
if(!fromApp) await startMaintenanceSchedule(batchCode);
|
||||
} else {
|
||||
scheduleJob(`startMainten${batchCode}`, maintenance.startTime * 1000, async () => {
|
||||
await startMaintenanceSchedule(batchCode);
|
||||
|
||||
Reference in New Issue
Block a user