mirror of https://github.com/certd/certd
perf: 任务支持禁用
parent
5b0f5f75d0
commit
8ed16b3ea2
|
@ -104,11 +104,18 @@ export class Executor {
|
|||
|
||||
async runWithHistory(runnable: Runnable, runnableType: string, run: () => Promise<ResultType | void>) {
|
||||
runnable.runnableType = runnableType;
|
||||
|
||||
this.runtime.start(runnable);
|
||||
// const timeout = runnable.timeout ?? 20 * 60 * 1000;
|
||||
await this.onChanged(this.runtime);
|
||||
|
||||
try {
|
||||
if (runnable.disabled) {
|
||||
//该任务被禁用
|
||||
this.runtime.disabled(runnable);
|
||||
return ResultType.disabled;
|
||||
}
|
||||
|
||||
await this.onChanged(this.runtime);
|
||||
|
||||
if (this.abort.signal.aborted) {
|
||||
this.runtime.cancel(runnable);
|
||||
return ResultType.canceled;
|
||||
|
|
|
@ -74,6 +74,17 @@ export class RunHistory {
|
|||
this.log(runnable, `跳过`);
|
||||
}
|
||||
|
||||
disabled(runnable: Runnable) {
|
||||
const now = new Date().getTime();
|
||||
const status = runnable.status;
|
||||
_.merge(status, {
|
||||
status: "canceled",
|
||||
endTime: now,
|
||||
result: "disabled",
|
||||
});
|
||||
this.log(runnable, `禁用`);
|
||||
}
|
||||
|
||||
error(runnable: Runnable, e: Error) {
|
||||
const now = new Date().getTime();
|
||||
const status = runnable.status;
|
||||
|
|
|
@ -70,6 +70,7 @@ export type Runnable = {
|
|||
default?: {
|
||||
[key: string]: any;
|
||||
};
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
export type EmailOptions = {
|
||||
|
@ -108,6 +109,7 @@ export enum ResultType {
|
|||
error = "error",
|
||||
canceled = "canceled",
|
||||
skip = "skip",
|
||||
disabled = "disabled",
|
||||
none = "none",
|
||||
}
|
||||
|
||||
|
|
|
@ -184,3 +184,12 @@ h1, h2, h3, h4, h5, h6 {
|
|||
.need-plus {
|
||||
color: #c5913f !important;
|
||||
}
|
||||
|
||||
|
||||
.disabled{
|
||||
color: #c7c7c7;
|
||||
}
|
||||
.deleted{
|
||||
//删除线
|
||||
text-decoration: line-through;
|
||||
}
|
|
@ -48,9 +48,10 @@
|
|||
<div class="step-row">
|
||||
<div class="text">
|
||||
<fs-icon icon="ion:flash"></fs-icon>
|
||||
<h4 class="title">{{ element.title }}</h4>
|
||||
<h4 class="title" :class="{ disabled: element.disabled, deleted: element.disabled }">{{ element.title }}</h4>
|
||||
</div>
|
||||
<div class="action">
|
||||
<a key="disabled" @click="element.disabled = !!!element.disabled">{{ element.disabled ? "启用" : "禁用" }}</a>
|
||||
<a key="edit" @click="stepEdit(currentTask, element, index)">编辑</a>
|
||||
<a key="edit" @click="stepCopy(currentTask, element, index)">复制</a>
|
||||
<a key="remove" @click="stepDelete(currentTask, index)">删除</a>
|
||||
|
|
|
@ -94,7 +94,9 @@
|
|||
<!-- :open="true"-->
|
||||
<template #content>
|
||||
<div v-for="(item, index) of task.steps" class="flex-o w-100">
|
||||
<span class="ellipsis flex-1">{{ index + 1 }}. {{ item.title }} </span>
|
||||
<span class="ellipsis flex-1 step-title" :class="{ disabled: item.disabled, deleted: item.disabled }">
|
||||
{{ index + 1 }}. {{ item.title }}
|
||||
</span>
|
||||
<pi-status-show v-if="!editMode" :status="item.status?.result"></pi-status-show>
|
||||
<fs-icon
|
||||
v-if="!editMode"
|
||||
|
@ -346,14 +348,23 @@ export default defineComponent({
|
|||
}
|
||||
const intervalLoadHistoryRef = ref();
|
||||
function watchNewHistoryList() {
|
||||
intervalLoadHistoryRef.value = setInterval(async () => {
|
||||
if (currentHistory.value == null) {
|
||||
await loadHistoryList();
|
||||
} else if (currentHistory.value.pipeline?.status?.status === "start") {
|
||||
await loadCurrentHistoryDetail();
|
||||
} else {
|
||||
clearInterval(intervalLoadHistoryRef.value);
|
||||
intervalLoadHistoryRef.value = setTimeout(async () => {
|
||||
try {
|
||||
if (currentHistory.value == null) {
|
||||
await loadHistoryList();
|
||||
}
|
||||
|
||||
if (!currentHistory.value) {
|
||||
if (currentHistory.value.pipeline?.status?.status === "start") {
|
||||
await loadCurrentHistoryDetail();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
watchNewHistoryList();
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,12 @@ const StatusEnum: StatusEnumType = {
|
|||
label: "未运行",
|
||||
color: "blue",
|
||||
icon: "ant-design:minus-circle-twotone"
|
||||
},
|
||||
disabled: {
|
||||
value: "disabled",
|
||||
label: "禁用",
|
||||
color: "gray",
|
||||
icon: "ant-design:stop-outlined"
|
||||
}
|
||||
};
|
||||
export const statusUtil = {
|
||||
|
|
|
@ -16,7 +16,9 @@
|
|||
"build": "mwtsc --cleanOutDir --skipLibCheck",
|
||||
"build-on-docker": "node ./before-build.js && npm run build",
|
||||
"up-mw-deps": "npx midway-version -u -w",
|
||||
"clinic": "clinic heapprofiler -- node ./bootstrap.js"
|
||||
"heap": "clinic heapprofiler -- node ./bootstrap.js",
|
||||
"flame": "clinic flame -- node ./bootstrap.js"
|
||||
|
||||
},
|
||||
"dependencies": {
|
||||
"@alicloud/cs20151215": "^3.0.3",
|
||||
|
|
Loading…
Reference in New Issue