mirror of
https://github.com/whyour/qinglong.git
synced 2025-07-27 14:46:06 +08:00
修复定时任务列表创建
This commit is contained in:
parent
748d00ae45
commit
eb9217d46e
|
@ -3,6 +3,7 @@ import { exec } from 'child_process';
|
|||
import Logger from './loaders/logger';
|
||||
import { Container } from 'typedi';
|
||||
import CronService from './services/cron';
|
||||
import { CrontabStatus } from './data/cron';
|
||||
|
||||
const run = async () => {
|
||||
const cronService = Container.get(CronService);
|
||||
|
@ -21,7 +22,11 @@ const run = async () => {
|
|||
for (let i = 0; i < docs.length; i++) {
|
||||
const task = docs[i];
|
||||
const _schedule = task.schedule && task.schedule.split(' ');
|
||||
if (_schedule && _schedule.length > 5) {
|
||||
if (
|
||||
_schedule &&
|
||||
_schedule.length > 5 &&
|
||||
task.status !== CrontabStatus.disabled
|
||||
) {
|
||||
schedule.scheduleJob(task.schedule, function () {
|
||||
exec(task.command);
|
||||
});
|
||||
|
|
|
@ -191,19 +191,17 @@ export default class CronService {
|
|||
var crontab_string = '';
|
||||
tabs.forEach((tab) => {
|
||||
const _schedule = tab.schedule && tab.schedule.split(' ');
|
||||
if (_schedule && _schedule.length === 5) {
|
||||
if (tab.status === CrontabStatus.disabled) {
|
||||
crontab_string += '# ';
|
||||
crontab_string += tab.schedule;
|
||||
crontab_string += ' ';
|
||||
crontab_string += this.make_command(tab);
|
||||
crontab_string += '\n';
|
||||
} else {
|
||||
crontab_string += tab.schedule;
|
||||
crontab_string += ' ';
|
||||
crontab_string += this.make_command(tab);
|
||||
crontab_string += '\n';
|
||||
}
|
||||
if (tab.status === CrontabStatus.disabled || _schedule.length !== 5) {
|
||||
crontab_string += '# ';
|
||||
crontab_string += tab.schedule;
|
||||
crontab_string += ' ';
|
||||
crontab_string += this.make_command(tab);
|
||||
crontab_string += '\n';
|
||||
} else {
|
||||
crontab_string += tab.schedule;
|
||||
crontab_string += ' ';
|
||||
crontab_string += this.make_command(tab);
|
||||
crontab_string += '\n';
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user