mirror of
https://gitee.com/devlive-community/datacap.git
synced 2024-12-02 20:17:45 +08:00
[Lib] [Shell] Support error output
This commit is contained in:
parent
2667aefd2a
commit
cdb2a93a84
@ -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>
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user