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 Logger from './loaders/logger';
|
||||||
import { Container } from 'typedi';
|
import { Container } from 'typedi';
|
||||||
import CronService from './services/cron';
|
import CronService from './services/cron';
|
||||||
|
import { CrontabStatus } from './data/cron';
|
||||||
|
|
||||||
const run = async () => {
|
const run = async () => {
|
||||||
const cronService = Container.get(CronService);
|
const cronService = Container.get(CronService);
|
||||||
|
@ -21,7 +22,11 @@ const run = async () => {
|
||||||
for (let i = 0; i < docs.length; i++) {
|
for (let i = 0; i < docs.length; i++) {
|
||||||
const task = docs[i];
|
const task = docs[i];
|
||||||
const _schedule = task.schedule && task.schedule.split(' ');
|
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 () {
|
schedule.scheduleJob(task.schedule, function () {
|
||||||
exec(task.command);
|
exec(task.command);
|
||||||
});
|
});
|
||||||
|
|
|
@ -191,19 +191,17 @@ export default class CronService {
|
||||||
var crontab_string = '';
|
var crontab_string = '';
|
||||||
tabs.forEach((tab) => {
|
tabs.forEach((tab) => {
|
||||||
const _schedule = tab.schedule && tab.schedule.split(' ');
|
const _schedule = tab.schedule && tab.schedule.split(' ');
|
||||||
if (_schedule && _schedule.length === 5) {
|
if (tab.status === CrontabStatus.disabled || _schedule.length !== 5) {
|
||||||
if (tab.status === CrontabStatus.disabled) {
|
crontab_string += '# ';
|
||||||
crontab_string += '# ';
|
crontab_string += tab.schedule;
|
||||||
crontab_string += tab.schedule;
|
crontab_string += ' ';
|
||||||
crontab_string += ' ';
|
crontab_string += this.make_command(tab);
|
||||||
crontab_string += this.make_command(tab);
|
crontab_string += '\n';
|
||||||
crontab_string += '\n';
|
} else {
|
||||||
} else {
|
crontab_string += tab.schedule;
|
||||||
crontab_string += tab.schedule;
|
crontab_string += ' ';
|
||||||
crontab_string += ' ';
|
crontab_string += this.make_command(tab);
|
||||||
crontab_string += this.make_command(tab);
|
crontab_string += '\n';
|
||||||
crontab_string += '\n';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user