[Lib] [Shell] Support error output

This commit is contained in:
qianmoQ 2023-03-15 22:13:28 +08:00
parent 2667aefd2a
commit cdb2a93a84
3 changed files with 27 additions and 4 deletions

View File

@ -57,7 +57,7 @@
<Badge v-if="applySource && activeEditorValue">
<Button type="primary" size="small" icon="md-ionitron" @click="handlerVisibleHelp(true)"></Button>
<template #count>
<Icon type="md-help-circle" color="#ed4014" size="16"/>
<Icon class="go" type="md-help-circle" color="#ed4014" size="20"/>
</template>
</Badge>
</Space>
@ -380,4 +380,17 @@ export default defineComponent({
.center {
text-align: center;
}
@keyframes changDeg {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.go {
animation: changDeg 2s linear 0.2s infinite;
}
</style>

View File

@ -5,6 +5,8 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import java.util.List;
@Data
@ToString
@AllArgsConstructor
@ -14,4 +16,5 @@ public class ShellResponse
private Integer code;
private Boolean successful;
private boolean timeout = false;
private List<String> errors;
}

View File

@ -56,7 +56,6 @@ public class ProcessBuilderCommander
Process process = null;
try {
builder.redirectErrorStream(true);
process = builder.start();
boolean exitCode = process.waitFor(configure.getTimeout(), TimeUnit.SECONDS);
if (!exitCode) {
@ -80,8 +79,17 @@ public class ProcessBuilderCommander
}
}
}
shellResponse.setCode(process.exitValue());
if (process.exitValue() > 0) {
List<String> errors = new ArrayList<>();
new BufferedReader(new InputStreamReader(process.getErrorStream(), StandardCharsets.UTF_8))
.lines()
.forEach(line -> {
logger.error(line);
errors.add(line);
});
shellResponse.setErrors(errors);
shellResponse.setSuccessful(Boolean.FALSE);
}
}
@ -93,9 +101,8 @@ public class ProcessBuilderCommander
if (ObjectUtils.isNotEmpty(process)) {
process.destroy();
}
logger.info("Execute response {}", shellResponse);
loggerExecutor.destroy();
logger.info("Execute end destroy logger components successful");
loggerExecutor.destroy();
}
return shellResponse;
}