perf: 支持已跳过的步骤重新运行

This commit is contained in:
xiaojunnuo
2024-09-02 18:36:12 +08:00
parent 724a85028b
commit ea775adae1
20 changed files with 105 additions and 87 deletions

View File

@@ -197,14 +197,14 @@ export class PipelineService extends BaseService<PipelineEntity> {
}
}
async trigger(id) {
async trigger(id: any, stepId?: string) {
this.cron.register({
name: `pipeline.${id}.trigger.once`,
cron: null,
job: async () => {
logger.info('用户手动启动job');
try {
await this.run(id, null);
await this.run(id, null, stepId);
} catch (e) {
logger.error('手动job执行失败', e);
}
@@ -279,7 +279,7 @@ export class PipelineService extends BaseService<PipelineEntity> {
logger.info('当前定时器数量:', this.cron.getTaskSize());
}
async run(id: number, triggerId: string) {
async run(id: number, triggerId: string, stepId?: string) {
const entity: PipelineEntity = await this.info(id);
const pipeline = JSON.parse(entity.content);
@@ -333,6 +333,10 @@ export class PipelineService extends BaseService<PipelineEntity> {
try {
runningTasks.set(historyId, executor);
await executor.init();
if (stepId) {
// 清除该step的状态
executor.clearLastStatus(stepId);
}
await executor.run(historyId, triggerType);
} catch (e) {
logger.error('执行失败:', e);