定时任务:修复自动开服开关

This commit is contained in:
luying
2022-05-11 15:16:11 +08:00
parent 0bc35aba54
commit 751c796a6b
3 changed files with 20 additions and 5 deletions

View File

@@ -645,10 +645,15 @@ export async function stopMaintenance(batchCode: string, serverIds: number[]) {
// —————————————— 自动开服 —————————————— //
export async function initAutoCreateServer(region?: RegionType) {
if(!region) region = await RegionModel.findRegionByEnv(pinus.app.get('env'));
if(region && region.stategy) {
for(let timer of region.stategy.timers) {
setStategyTimer(timer, region)
}
if(region && region.stategy && region.stategy.isOpen) {
for(let timer of region.stategy.timers) {
setStategyTimer(timer, region)
}
} else {
if(scheduledJobs[`autoServer${SERVER_TIMER.FIVE_HALF}`]) scheduledJobs[`autoServer${SERVER_TIMER.FIVE_HALF}`].cancel();
if(scheduledJobs[`autoServer${SERVER_TIMER.TEN_HALF}`]) scheduledJobs[`autoServer${SERVER_TIMER.FIVE_HALF}`].cancel();
if(scheduledJobs[`autoServer${SERVER_TIMER.FIFTEEN_HALF}`]) scheduledJobs[`autoServer${SERVER_TIMER.FIVE_HALF}`].cancel();
if(scheduledJobs[`autoServer${SERVER_TIMER.NINETEEN_HALF}`]) scheduledJobs[`autoServer${SERVER_TIMER.FIVE_HALF}`].cancel();
}
}