mirror of https://github.com/certd/certd
perf: flush logger
parent
f87eee3b9f
commit
91be6826b9
|
@ -50,6 +50,8 @@ export class Executor {
|
||||||
this.lastStatusMap = new RunnableCollection(lastRuntime?.pipeline);
|
this.lastStatusMap = new RunnableCollection(lastRuntime?.pipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async cancel() {}
|
||||||
|
|
||||||
async run(runtimeId: any = 0, triggerType: string) {
|
async run(runtimeId: any = 0, triggerType: string) {
|
||||||
try {
|
try {
|
||||||
await this.init();
|
await this.init();
|
||||||
|
@ -99,17 +101,20 @@ export class Executor {
|
||||||
return ResultType.skip;
|
return ResultType.skip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const timer = setInterval(async () => {
|
||||||
|
await this.onChanged(this.runtime);
|
||||||
|
}, 10000);
|
||||||
try {
|
try {
|
||||||
await run();
|
await run();
|
||||||
this.runtime.success(runnable);
|
this.runtime.success(runnable);
|
||||||
await this.onChanged(this.runtime);
|
|
||||||
return ResultType.success;
|
return ResultType.success;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
this.runtime.error(runnable, e);
|
this.runtime.error(runnable, e);
|
||||||
await this.onChanged(this.runtime);
|
|
||||||
throw e;
|
throw e;
|
||||||
} finally {
|
} finally {
|
||||||
this.runtime.finally(runnable);
|
this.runtime.finally(runnable);
|
||||||
|
clearInterval(timer);
|
||||||
|
await this.onChanged(this.runtime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,8 @@ import { HistoryLogService } from './history-log-service';
|
||||||
import { logger } from '../../../utils/logger';
|
import { logger } from '../../../utils/logger';
|
||||||
import { EmailService } from '../../basic/service/email-service';
|
import { EmailService } from '../../basic/service/email-service';
|
||||||
|
|
||||||
|
const runningTasks: Map<string | number, Executor> = new Map();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 证书申请
|
* 证书申请
|
||||||
*/
|
*/
|
||||||
|
@ -178,7 +180,7 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async run(id, triggerId) {
|
async run(id: number, triggerId: string) {
|
||||||
const entity: PipelineEntity = await this.info(id);
|
const entity: PipelineEntity = await this.info(id);
|
||||||
const pipeline = JSON.parse(entity.content);
|
const pipeline = JSON.parse(entity.content);
|
||||||
|
|
||||||
|
@ -219,11 +221,14 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||||
fileRootDir: this.certdConfig.fileRootDir,
|
fileRootDir: this.certdConfig.fileRootDir,
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
|
runningTasks.set(id, executor);
|
||||||
await executor.init();
|
await executor.init();
|
||||||
await executor.run(historyId, triggerType);
|
await executor.run(historyId, triggerType);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error('执行失败:', e);
|
logger.error('执行失败:', e);
|
||||||
throw e;
|
throw e;
|
||||||
|
} finally {
|
||||||
|
runningTasks.delete(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue