mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-29 02:56:08 +08:00
修复初始化定时服务运行非禁用任务
This commit is contained in:
parent
4a0c66bcc0
commit
f267720af4
|
@ -10,6 +10,9 @@ const addCron = (
|
||||||
) => {
|
) => {
|
||||||
for (const item of call.request.crons) {
|
for (const item of call.request.crons) {
|
||||||
const { id, schedule, command } = item;
|
const { id, schedule, command } = item;
|
||||||
|
if (scheduleStacks.has(id)) {
|
||||||
|
scheduleStacks.get(id)?.cancel();
|
||||||
|
}
|
||||||
scheduleStacks.set(
|
scheduleStacks.set(
|
||||||
id,
|
id,
|
||||||
nodeSchedule.scheduleJob(id, schedule, async () => {
|
nodeSchedule.scheduleJob(id, schedule, async () => {
|
||||||
|
|
|
@ -19,7 +19,7 @@ import cronClient from '../schedule/client';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export default class CronService {
|
export default class CronService {
|
||||||
constructor(@Inject('logger') private logger: winston.Logger) {}
|
constructor(@Inject('logger') private logger: winston.Logger) { }
|
||||||
|
|
||||||
private isSixCron(cron: Crontab) {
|
private isSixCron(cron: Crontab) {
|
||||||
const { schedule } = cron;
|
const { schedule } = cron;
|
||||||
|
@ -51,6 +51,9 @@ export default class CronService {
|
||||||
const tab = new Crontab({ ...doc, ...payload });
|
const tab = new Crontab({ ...doc, ...payload });
|
||||||
tab.saved = false;
|
tab.saved = false;
|
||||||
const newDoc = await this.updateDb(tab);
|
const newDoc = await this.updateDb(tab);
|
||||||
|
if (doc.isDisabled === 1) {
|
||||||
|
return newDoc;
|
||||||
|
}
|
||||||
if (this.isSixCron(doc)) {
|
if (this.isSixCron(doc)) {
|
||||||
await cronClient.delCron([String(newDoc.id)]);
|
await cronClient.delCron([String(newDoc.id)]);
|
||||||
}
|
}
|
||||||
|
@ -581,7 +584,7 @@ export default class CronService {
|
||||||
this.set_crontab(tabs);
|
this.set_crontab(tabs);
|
||||||
|
|
||||||
const sixCron = tabs.data
|
const sixCron = tabs.data
|
||||||
.filter((x) => this.isSixCron(x))
|
.filter((x) => this.isSixCron(x) && x.isDisabled !== 1)
|
||||||
.map((doc) => ({
|
.map((doc) => ({
|
||||||
id: String(doc.id),
|
id: String(doc.id),
|
||||||
schedule: doc.schedule!,
|
schedule: doc.schedule!,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user