mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 14:56:07 +08:00
添加检查更新和删除日志频率操作
This commit is contained in:
parent
d6ebd2699e
commit
9455ca64a2
|
@ -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] } },
|
||||
|
|
|
@ -328,6 +328,12 @@ const Setting = ({
|
|||
buttonStyle="solid"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="日志删除频率" name="frequency" initialValue={0}>
|
||||
<Input addonBefore="每" addonAfter="天" style={{ width: 300 }} />
|
||||
</Form.Item>
|
||||
<Form.Item label="检查更新" name="theme" initialValue={theme}>
|
||||
<Button type="primary">检查更新</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Tabs.TabPane>
|
||||
</Tabs>
|
||||
|
|
Loading…
Reference in New Issue
Block a user