mirror of https://github.com/certd/certd
chore: off cron when remove
parent
f04e497999
commit
301f6cc273
|
@ -60,7 +60,8 @@ export class PipelineController extends CrudController<PipelineService> {
|
|||
@Post('/delete', { summary: Constants.per.authOnly })
|
||||
async delete(@Query('id') id) {
|
||||
await this.service.checkUserId(id, this.ctx.user.id);
|
||||
return super.delete(id);
|
||||
await this.service.delete(id);
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
@Post('/detail', { summary: Constants.per.authOnly })
|
||||
|
|
|
@ -136,6 +136,25 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
|||
logger.info('定时器数量:', this.cron.getListSize());
|
||||
}
|
||||
|
||||
async delete(id: number) {
|
||||
const pipeline = await this.info(id);
|
||||
if (!pipeline) {
|
||||
return;
|
||||
}
|
||||
const pipelineObj = JSON.parse(pipeline.content);
|
||||
if (pipelineObj.triggers) {
|
||||
for (const trigger of pipelineObj.triggers) {
|
||||
this.removeCron(id, trigger);
|
||||
}
|
||||
}
|
||||
await super.delete([id]);
|
||||
}
|
||||
|
||||
removeCron(pipelineId, trigger) {
|
||||
const name = this.buildCronKey(pipelineId, trigger.id);
|
||||
this.cron.remove(name);
|
||||
}
|
||||
|
||||
registerCron(pipelineId, trigger) {
|
||||
let cron = trigger.props?.cron;
|
||||
if (cron == null) {
|
||||
|
|
Loading…
Reference in New Issue