系统重启时会执行一次所有ql repo 和 ql raw的定时任务

This commit is contained in:
whyour 2021-05-12 20:36:47 +08:00
parent ed9db7c8d5
commit 5ddc9ac22e

View File

@ -1,3 +1,4 @@
import { exec } from 'child_process';
import { Container } from 'typedi';
import { Crontab, CrontabStatus } from '../data/cron';
import CronService from '../services/cron';
@ -48,6 +49,7 @@ export default async () => {
}
});
// patch更新面板任务状态
cronDb.find({ name: '更新面板' }).exec((err, docs) => {
const doc = docs[0];
if (doc && doc.status === CrontabStatus.running) {
@ -57,6 +59,18 @@ export default async () => {
);
}
});
// 初始化时执行一次所有的ql repo 任务
cronDb
.find({
command: /ql (repo|raw)/,
})
.exec((err, docs) => {
for (let i = 0; i < docs.length; i++) {
const doc = docs[i];
exec(doc.command);
}
});
};
function randomSchedule(from: number, to: number) {