mirror of
https://github.com/cool-team-official/cool-admin-midway.git
synced 2026-02-06 18:15:35 +00:00
修复任务无法停止
This commit is contained in:
parent
0463738b53
commit
3c8f48f4f5
@ -40,9 +40,10 @@ export class TaskInfoService extends BaseService {
|
|||||||
async stop(id) {
|
async stop(id) {
|
||||||
const task = await this.taskInfoEntity.findOne({ id });
|
const task = await this.taskInfoEntity.findOne({ id });
|
||||||
if (task) {
|
if (task) {
|
||||||
const job = await this.exist(task.id);
|
const result = await this.taskInfoQueue.getRepeatableJobs();
|
||||||
|
const job = _.find(result, { id: task.id + '' });
|
||||||
if (job) {
|
if (job) {
|
||||||
await this.taskInfoQueue.removeRepeatable(JSON.parse(task.repeatConf));
|
await this.taskInfoQueue.removeRepeatableByKey(job.key);
|
||||||
}
|
}
|
||||||
task.status = 0;
|
task.status = 0;
|
||||||
await this.taskInfoEntity.update(task.id, task);
|
await this.taskInfoEntity.update(task.id, task);
|
||||||
@ -115,9 +116,7 @@ export class TaskInfoService extends BaseService {
|
|||||||
if (params.status === 1) {
|
if (params.status === 1) {
|
||||||
const exist = await this.exist(params.id);
|
const exist = await this.exist(params.id);
|
||||||
if (exist) {
|
if (exist) {
|
||||||
await this.taskInfoQueue.removeRepeatable(
|
this.stop(params.id);
|
||||||
JSON.parse(params.repeatConf)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
const { every, limit, startDate, endDate, cron } = params;
|
const { every, limit, startDate, endDate, cron } = params;
|
||||||
const repeat = {
|
const repeat = {
|
||||||
@ -169,7 +168,7 @@ export class TaskInfoService extends BaseService {
|
|||||||
const task = await this.taskInfoEntity.findOne({ id });
|
const task = await this.taskInfoEntity.findOne({ id });
|
||||||
const exist = await this.exist(task.id);
|
const exist = await this.exist(task.id);
|
||||||
if (exist) {
|
if (exist) {
|
||||||
await this.taskInfoQueue.removeRepeatable(JSON.parse(task.repeatConf));
|
this.stop(task.id);
|
||||||
}
|
}
|
||||||
await this.taskInfoEntity.delete({ id });
|
await this.taskInfoEntity.delete({ id });
|
||||||
await this.taskLogEntity.delete({ taskId: id });
|
await this.taskLogEntity.delete({ taskId: id });
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user