[ Service ] [ Executor ] 重构Executor部分
This commit is contained in:
@@ -32,7 +32,10 @@ func ReadTimeCommandExecutor(singleLineCommand []string) {
|
||||
}
|
||||
|
||||
// AllOutputCommandExecutor 收集全部执行结果、错误并且返回
|
||||
func AllOutputCommandExecutor(singleLineCommand []string) []string {
|
||||
func AllOutputCommandExecutor(singleLineCommand []string) ([]string, error) {
|
||||
|
||||
// result
|
||||
var resultSlice []string
|
||||
|
||||
cmd := exec.Command(singleLineCommand[0], singleLineCommand[1:]...)
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
@@ -48,17 +51,18 @@ func AllOutputCommandExecutor(singleLineCommand []string) []string {
|
||||
log.ErrorF("command %v runtime error => %v", singleLineCommand, err)
|
||||
}
|
||||
|
||||
var resultSlice []string
|
||||
resultSlice = append(resultSlice, "👇👇👇 命令 输出 信息如下 👇👇👇")
|
||||
resultSlice = append(resultSlice, collectOutput(stdout, resultSlice)...)
|
||||
resultSlice = append(resultSlice, "👇👇👇 命令 错误 信息如下 👇👇👇")
|
||||
resultSlice = append(resultSlice, collectOutput(stderr, resultSlice)...)
|
||||
|
||||
if err := cmd.Wait(); err != nil {
|
||||
log.ErrorF("command %v result error => %v", singleLineCommand, err)
|
||||
}
|
||||
|
||||
//log.DebugF("real time exec result are %v", resultSlice)
|
||||
log.DebugF("real time exec result are %v", resultSlice)
|
||||
|
||||
return resultSlice
|
||||
return resultSlice, nil
|
||||
}
|
||||
|
||||
func realTimeOutput(r io.Reader) {
|
||||
|
||||
Reference in New Issue
Block a user