mirror of
https://github.com/whyour/qinglong.git
synced 2026-06-30 20:35:09 +08:00
添加检查更新和删除日志频率操作
This commit is contained in:
@@ -4,24 +4,6 @@ import { Crontab, CrontabStatus } from '../data/cron';
|
||||
import CronService from '../services/cron';
|
||||
import EnvService from '../services/env';
|
||||
|
||||
const initData = [
|
||||
{
|
||||
name: '更新面板',
|
||||
command: `ql update`,
|
||||
schedule: `${randomSchedule(60, 1)} ${randomSchedule(
|
||||
6,
|
||||
1,
|
||||
).toString()} * * *`,
|
||||
isDisabled: 1,
|
||||
},
|
||||
{
|
||||
name: '删除日志',
|
||||
command: 'ql rmlog 7',
|
||||
schedule: '30 7 */7 * *',
|
||||
isDisabled: 1,
|
||||
},
|
||||
];
|
||||
|
||||
export default async () => {
|
||||
const cronService = Container.get(CronService);
|
||||
const envService = Container.get(EnvService);
|
||||
@@ -32,24 +14,6 @@ export default async () => {
|
||||
cronDb.persistence.compactDatafile();
|
||||
envDb.persistence.compactDatafile();
|
||||
|
||||
cronDb.count({}, async (err, count) => {
|
||||
if (count === 0) {
|
||||
const data = initData.map((x: any) => {
|
||||
const tab = new Crontab(x);
|
||||
tab.created = new Date().valueOf();
|
||||
tab.saved = false;
|
||||
if (tab.name === '更新面板') {
|
||||
tab.isSystem = 1;
|
||||
} else {
|
||||
tab.isSystem = 0;
|
||||
}
|
||||
return tab;
|
||||
});
|
||||
cronDb.insert(data);
|
||||
await cronService.autosave_crontab();
|
||||
}
|
||||
});
|
||||
|
||||
// 初始化更新所有任务状态为空闲
|
||||
cronDb.update(
|
||||
{ status: { $in: [CrontabStatus.running, CrontabStatus.queued] } },
|
||||
|
||||
Reference in New Issue
Block a user