From bf0263c0cdeb235d05e9fb98756573df98189441 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Wed, 19 Jun 2024 17:36:53 +0800 Subject: [PATCH 01/70] Update task.go --- ibex/task.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ibex/task.go b/ibex/task.go index 3625b01e..69c48ef9 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -286,7 +286,20 @@ func (t *Task) start() { cmd.Stdin = t.Stdin t.Cmd = cmd + stdout, err := cmd.StdoutPipe() + err = CmdStart(cmd) + + // 从管道中实时获取输出并打印到终端 + for { + tmp := make([]byte, 1024) + _, err := stdout.Read(tmp) + log.Printf("======> %s", string(tmp)) + if err != nil { + log.Printf("ERROR ======> %s", string(tmp)) + break + } + } if err != nil { log.Printf("E! cannot start cmd of task[%d]: %v", t.Id, err) return From 5e6dc8b9a76ddb0db866527bbf36d99909569abd Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Wed, 19 Jun 2024 23:25:20 +0800 Subject: [PATCH 02/70] Update task.go --- ibex/task.go | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 69c48ef9..288b404a 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -3,9 +3,12 @@ package ibex import ( + "bufio" "bytes" "fmt" + "io" "log" + "os" "os/exec" "os/user" "path" @@ -286,27 +289,47 @@ func (t *Task) start() { cmd.Stdin = t.Stdin t.Cmd = cmd + var wg sync.WaitGroup + wg.Add(2) + //捕获标准输出 stdout, err := cmd.StdoutPipe() + if err != nil { + fmt.Println("INFO:", err) + os.Exit(1) + } + readout := bufio.NewReader(stdout) + go func() { + defer wg.Done() + GetOutput(readout) + }() err = CmdStart(cmd) - // 从管道中实时获取输出并打印到终端 - for { - tmp := make([]byte, 1024) - _, err := stdout.Read(tmp) - log.Printf("======> %s", string(tmp)) - if err != nil { - log.Printf("ERROR ======> %s", string(tmp)) - break - } - } if err != nil { log.Printf("E! cannot start cmd of task[%d]: %v", t.Id, err) return } + wg.Wait() go runProcess(t) } +func GetOutput(reader *bufio.Reader) { + var sumOutput string //统计屏幕的全部输出内容 + outputBytes := make([]byte, 200) + for { + n, err := reader.Read(outputBytes) //获取屏幕的实时输出(并不是按照回车分割,所以要结合sumOutput) + if err != nil { + if err == io.EOF { + break + } + fmt.Println(err) + sumOutput += err.Error() + } + output := string(outputBytes[:n]) + fmt.Print(output) //输出屏幕内容 + sumOutput += output + } +} func (t *Task) kill() { go killProcess(t) From 6c8da2bbb42d7d65a6b718454e9f929e600c741c Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Wed, 19 Jun 2024 23:35:01 +0800 Subject: [PATCH 03/70] Update task.go --- ibex/task.go | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 288b404a..65663435 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -8,7 +8,6 @@ import ( "fmt" "io" "log" - "os" "os/exec" "os/user" "path" @@ -289,27 +288,23 @@ func (t *Task) start() { cmd.Stdin = t.Stdin t.Cmd = cmd - var wg sync.WaitGroup - wg.Add(2) - //捕获标准输出 - stdout, err := cmd.StdoutPipe() - if err != nil { - fmt.Println("INFO:", err) - os.Exit(1) - } - readout := bufio.NewReader(stdout) - go func() { - defer wg.Done() - GetOutput(readout) - }() - err = CmdStart(cmd) - if err != nil { log.Printf("E! cannot start cmd of task[%d]: %v", t.Id, err) return } - wg.Wait() + + stdout, err := cmd.StdoutPipe() + reader := bufio.NewReader(stdout) + + //实时循环读取输出流中的一行内容 + for { + line, err2 := reader.ReadString('\n') + if err2 != nil || io.EOF == err2 { + break + } + fmt.Println(line) + } go runProcess(t) } From dc4f6cef918573e9773c6bdfaf799ed0e28dd89b Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Wed, 19 Jun 2024 23:38:00 +0800 Subject: [PATCH 04/70] Update task.go --- ibex/task.go | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 65663435..aa15ec27 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -306,24 +306,7 @@ func (t *Task) start() { fmt.Println(line) } - go runProcess(t) -} -func GetOutput(reader *bufio.Reader) { - var sumOutput string //统计屏幕的全部输出内容 - outputBytes := make([]byte, 200) - for { - n, err := reader.Read(outputBytes) //获取屏幕的实时输出(并不是按照回车分割,所以要结合sumOutput) - if err != nil { - if err == io.EOF { - break - } - fmt.Println(err) - sumOutput += err.Error() - } - output := string(outputBytes[:n]) - fmt.Print(output) //输出屏幕内容 - sumOutput += output - } + runProcess(t) } func (t *Task) kill() { From 1d048ea0f0db02544a9e50731357e3502c730b0f Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Wed, 19 Jun 2024 23:40:13 +0800 Subject: [PATCH 05/70] Update task.go --- ibex/task.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ibex/task.go b/ibex/task.go index aa15ec27..2bc5c4b3 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -306,6 +306,8 @@ func (t *Task) start() { fmt.Println(line) } + cmd.Wait() + runProcess(t) } From e643a7704e4a150f428c17cdd6dd3d8537487425 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Wed, 19 Jun 2024 23:45:14 +0800 Subject: [PATCH 06/70] Update task.go --- ibex/task.go | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 2bc5c4b3..8981f96c 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -294,7 +294,18 @@ func (t *Task) start() { return } - stdout, err := cmd.StdoutPipe() + go runProcess(t) +} + +func (t *Task) kill() { + go killProcess(t) +} + +func runProcess(t *Task) { + t.SetAlive(true) + defer t.SetAlive(false) + + stdout, err := t.Cmd.StdoutPipe() reader := bufio.NewReader(stdout) //实时循环读取输出流中的一行内容 @@ -306,20 +317,7 @@ func (t *Task) start() { fmt.Println(line) } - cmd.Wait() - - runProcess(t) -} - -func (t *Task) kill() { - go killProcess(t) -} - -func runProcess(t *Task) { - t.SetAlive(true) - defer t.SetAlive(false) - - err := t.Cmd.Wait() + err = t.Cmd.Wait() if err != nil { if strings.Contains(err.Error(), "signal: killed") { t.SetStatus("killed") From a814cc73d9ff686a66a7d272a0d2097d90033879 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Wed, 19 Jun 2024 23:47:11 +0800 Subject: [PATCH 07/70] Update task.go --- ibex/task.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibex/task.go b/ibex/task.go index 8981f96c..4a4a5c62 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -307,7 +307,7 @@ func runProcess(t *Task) { stdout, err := t.Cmd.StdoutPipe() reader := bufio.NewReader(stdout) - + fmt.Println(reader) //实时循环读取输出流中的一行内容 for { line, err2 := reader.ReadString('\n') From 3464c22ab52234fc08ce414f5835cc25ff1ded6e Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 00:06:12 +0800 Subject: [PATCH 08/70] Update task.go --- ibex/task.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ibex/task.go b/ibex/task.go index 4a4a5c62..13055604 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -306,8 +306,12 @@ func runProcess(t *Task) { defer t.SetAlive(false) stdout, err := t.Cmd.StdoutPipe() + if err != nil { + fmt.Println("error ===》 ", err) + } + fmt.Println(stdout) reader := bufio.NewReader(stdout) - fmt.Println(reader) + //实时循环读取输出流中的一行内容 for { line, err2 := reader.ReadString('\n') From 7e09590e705b2a7006291c29c7c50b51f29bf696 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 00:14:59 +0800 Subject: [PATCH 09/70] Update task.go --- ibex/task.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibex/task.go b/ibex/task.go index 13055604..5e4978b6 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -321,7 +321,7 @@ func runProcess(t *Task) { fmt.Println(line) } - err = t.Cmd.Wait() + //err = t.Cmd.Wait() if err != nil { if strings.Contains(err.Error(), "signal: killed") { t.SetStatus("killed") From fba25cb56c761de49e0f3ec73631a33b47672968 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 00:19:37 +0800 Subject: [PATCH 10/70] d --- ibex/task.go | 2 +- ibex/tasks.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 5e4978b6..13055604 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -321,7 +321,7 @@ func runProcess(t *Task) { fmt.Println(line) } - //err = t.Cmd.Wait() + err = t.Cmd.Wait() if err != nil { if strings.Contains(err.Error(), "signal: killed") { t.SetStatus("killed") diff --git a/ibex/tasks.go b/ibex/tasks.go index 954e07fc..9d610fbb 100644 --- a/ibex/tasks.go +++ b/ibex/tasks.go @@ -112,7 +112,7 @@ func (lt *LocalTasksT) Clean(assigned map[int64]struct{}) { continue } - lt.M[id].ResetBuff() + //lt.M[id].ResetBuff() cmd := lt.M[id].Cmd delete(lt.M, id) if cmd != nil && cmd.Process != nil { From 2e3e1b376856cafe87fcc6389e0deed1f85c755b Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 10:24:39 +0800 Subject: [PATCH 11/70] aa --- ibex/task.go | 2 +- ibex/tasks.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 13055604..b9237372 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -283,7 +283,7 @@ func (t *Task) start() { } } - cmd.Stdout = &t.Stdout + //cmd.Stdout = &t.Stdout cmd.Stderr = &t.Stderr cmd.Stdin = t.Stdin t.Cmd = cmd diff --git a/ibex/tasks.go b/ibex/tasks.go index 9d610fbb..954e07fc 100644 --- a/ibex/tasks.go +++ b/ibex/tasks.go @@ -112,7 +112,7 @@ func (lt *LocalTasksT) Clean(assigned map[int64]struct{}) { continue } - //lt.M[id].ResetBuff() + lt.M[id].ResetBuff() cmd := lt.M[id].Cmd delete(lt.M, id) if cmd != nil && cmd.Process != nil { From 52df0b8a6819f9ce5b368d43df8b613ed3aa60f3 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 10:27:47 +0800 Subject: [PATCH 12/70] Update task.go --- ibex/task.go | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index b9237372..8441158c 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -288,6 +288,22 @@ func (t *Task) start() { cmd.Stdin = t.Stdin t.Cmd = cmd + stdout, err := cmd.StdoutPipe() + if err != nil { + fmt.Println("error ===》 ", err) + } + fmt.Println(stdout) + reader := bufio.NewReader(stdout) + + //实时循环读取输出流中的一行内容 + for { + line, err2 := reader.ReadString('\n') + if err2 != nil || io.EOF == err2 { + break + } + fmt.Println(line) + } + err = CmdStart(cmd) if err != nil { log.Printf("E! cannot start cmd of task[%d]: %v", t.Id, err) @@ -305,23 +321,7 @@ func runProcess(t *Task) { t.SetAlive(true) defer t.SetAlive(false) - stdout, err := t.Cmd.StdoutPipe() - if err != nil { - fmt.Println("error ===》 ", err) - } - fmt.Println(stdout) - reader := bufio.NewReader(stdout) - - //实时循环读取输出流中的一行内容 - for { - line, err2 := reader.ReadString('\n') - if err2 != nil || io.EOF == err2 { - break - } - fmt.Println(line) - } - - err = t.Cmd.Wait() + err := t.Cmd.Wait() if err != nil { if strings.Contains(err.Error(), "signal: killed") { t.SetStatus("killed") From 8c09ade69ae55df1dd62a54761d15a32ea8ec068 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 10:46:03 +0800 Subject: [PATCH 13/70] Update task.go --- ibex/task.go | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 8441158c..ee224650 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -3,10 +3,8 @@ package ibex import ( - "bufio" "bytes" "fmt" - "io" "log" "os/exec" "os/user" @@ -71,6 +69,7 @@ func (t *Task) SetAlive(pa bool) { func (t *Task) GetStdout() string { t.Lock() out := t.Stdout.String() + fmt.Sprintf("Output =====> %s", out) t.Unlock() return out } @@ -283,26 +282,12 @@ func (t *Task) start() { } } - //cmd.Stdout = &t.Stdout + cmd.Stdout = &t.Stdout cmd.Stderr = &t.Stderr cmd.Stdin = t.Stdin t.Cmd = cmd - stdout, err := cmd.StdoutPipe() - if err != nil { - fmt.Println("error ===》 ", err) - } - fmt.Println(stdout) - reader := bufio.NewReader(stdout) - - //实时循环读取输出流中的一行内容 - for { - line, err2 := reader.ReadString('\n') - if err2 != nil || io.EOF == err2 { - break - } - fmt.Println(line) - } + persistResult(t) err = CmdStart(cmd) if err != nil { @@ -339,7 +324,7 @@ func runProcess(t *Task) { log.Printf("D! process of task[%d] done", t.Id) } - persistResult(t) + //persistResult(t) } func persistResult(t *Task) { @@ -349,7 +334,14 @@ func persistResult(t *Task) { stderr := filepath.Join(metadir, fmt.Sprint(t.Id), "stderr") doneFlag := filepath.Join(metadir, fmt.Sprint(t.Id), fmt.Sprintf("%d.done", t.Clock)) - file.WriteString(stdout, t.GetStdout()) + for { + out := t.GetStdout() + if out == "" { + break + } + file.WriteString(stdout, out) + } + file.WriteString(stderr, t.GetStderr()) file.WriteString(doneFlag, t.GetStatus()) } From 5f07571160b27bfc3570d0791469177d109e6899 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 10:48:50 +0800 Subject: [PATCH 14/70] Update task.go --- ibex/task.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ibex/task.go b/ibex/task.go index ee224650..fb38915b 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -69,7 +69,6 @@ func (t *Task) SetAlive(pa bool) { func (t *Task) GetStdout() string { t.Lock() out := t.Stdout.String() - fmt.Sprintf("Output =====> %s", out) t.Unlock() return out } @@ -328,6 +327,7 @@ func runProcess(t *Task) { } func persistResult(t *Task) { + fmt.Println("Enter Output") metadir := config.Config.Ibex.MetaDir stdout := filepath.Join(metadir, fmt.Sprint(t.Id), "stdout") @@ -336,6 +336,7 @@ func persistResult(t *Task) { for { out := t.GetStdout() + fmt.Sprintf("Output =====> %s", out) if out == "" { break } From e89c36fb65adc6aa5e0cdf9d29a00d629a7d0581 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 10:52:51 +0800 Subject: [PATCH 15/70] Update task.go --- ibex/task.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index fb38915b..300be01a 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -286,7 +286,7 @@ func (t *Task) start() { cmd.Stdin = t.Stdin t.Cmd = cmd - persistResult(t) + //persistResult(t) err = CmdStart(cmd) if err != nil { @@ -323,7 +323,7 @@ func runProcess(t *Task) { log.Printf("D! process of task[%d] done", t.Id) } - //persistResult(t) + persistResult(t) } func persistResult(t *Task) { From 3bcf0550a18cd41e4cd7c8af75a87978e0702748 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 10:59:18 +0800 Subject: [PATCH 16/70] Update task.go --- ibex/task.go | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 300be01a..951eeff7 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -286,14 +286,14 @@ func (t *Task) start() { cmd.Stdin = t.Stdin t.Cmd = cmd - //persistResult(t) - err = CmdStart(cmd) if err != nil { log.Printf("E! cannot start cmd of task[%d]: %v", t.Id, err) return } + persistResult(t) + go runProcess(t) } @@ -323,7 +323,7 @@ func runProcess(t *Task) { log.Printf("D! process of task[%d] done", t.Id) } - persistResult(t) + //persistResult(t) } func persistResult(t *Task) { @@ -334,14 +334,11 @@ func persistResult(t *Task) { stderr := filepath.Join(metadir, fmt.Sprint(t.Id), "stderr") doneFlag := filepath.Join(metadir, fmt.Sprint(t.Id), fmt.Sprintf("%d.done", t.Clock)) - for { - out := t.GetStdout() - fmt.Sprintf("Output =====> %s", out) - if out == "" { - break - } - file.WriteString(stdout, out) - } + //{ + out := t.GetStdout() + fmt.Sprintf("Output =====> %s", out) + file.WriteString(stdout, out) + //} file.WriteString(stderr, t.GetStderr()) file.WriteString(doneFlag, t.GetStatus()) From f18b617cb865356217dda5a0a45b61e27e14c4c5 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:01:00 +0800 Subject: [PATCH 17/70] Update task.go --- ibex/task.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 951eeff7..0d32292c 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -292,7 +292,7 @@ func (t *Task) start() { return } - persistResult(t) + //persistResult(t) go runProcess(t) } @@ -323,7 +323,7 @@ func runProcess(t *Task) { log.Printf("D! process of task[%d] done", t.Id) } - //persistResult(t) + persistResult(t) } func persistResult(t *Task) { From 2cce027f9326625b3b7a401d5dcc45c223300303 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:03:12 +0800 Subject: [PATCH 18/70] Update task.go --- ibex/task.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibex/task.go b/ibex/task.go index 0d32292c..6ab87bc8 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -336,7 +336,7 @@ func persistResult(t *Task) { //{ out := t.GetStdout() - fmt.Sprintf("Output =====> %s", out) + fmt.Sprintf("Output =====> %s", stdout) file.WriteString(stdout, out) //} From 28891f463ec66ca0bcfacf1fc80b421fa4c05f19 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:05:03 +0800 Subject: [PATCH 19/70] Update task.go --- ibex/task.go | 1 + 1 file changed, 1 insertion(+) diff --git a/ibex/task.go b/ibex/task.go index 6ab87bc8..72ddd0b2 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -335,6 +335,7 @@ func persistResult(t *Task) { doneFlag := filepath.Join(metadir, fmt.Sprint(t.Id), fmt.Sprintf("%d.done", t.Clock)) //{ + fmt.Sprintf("stdout =====> %s", stdout) out := t.GetStdout() fmt.Sprintf("Output =====> %s", stdout) file.WriteString(stdout, out) From 9f62297370dd43536daed470afb88c64645dd912 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:07:35 +0800 Subject: [PATCH 20/70] Update task.go --- ibex/task.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 72ddd0b2..e977e5d7 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -331,13 +331,15 @@ func persistResult(t *Task) { metadir := config.Config.Ibex.MetaDir stdout := filepath.Join(metadir, fmt.Sprint(t.Id), "stdout") + fmt.Sprintln("1") stderr := filepath.Join(metadir, fmt.Sprint(t.Id), "stderr") + fmt.Sprintln("2") doneFlag := filepath.Join(metadir, fmt.Sprint(t.Id), fmt.Sprintf("%d.done", t.Clock)) //{ - fmt.Sprintf("stdout =====> %s", stdout) + fmt.Sprintln("stdout =====> ", stdout) out := t.GetStdout() - fmt.Sprintf("Output =====> %s", stdout) + fmt.Sprintln("Output =====> ", stdout) file.WriteString(stdout, out) //} From 03f3a87e3c431c314828cc18216ef3dec0baf820 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:11:05 +0800 Subject: [PATCH 21/70] Update task.go --- ibex/task.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index e977e5d7..2366ff9c 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -329,17 +329,17 @@ func runProcess(t *Task) { func persistResult(t *Task) { fmt.Println("Enter Output") metadir := config.Config.Ibex.MetaDir - + fmt.Println("0") stdout := filepath.Join(metadir, fmt.Sprint(t.Id), "stdout") - fmt.Sprintln("1") + fmt.Println("1") stderr := filepath.Join(metadir, fmt.Sprint(t.Id), "stderr") - fmt.Sprintln("2") + fmt.Println("2") doneFlag := filepath.Join(metadir, fmt.Sprint(t.Id), fmt.Sprintf("%d.done", t.Clock)) //{ - fmt.Sprintln("stdout =====> ", stdout) + fmt.Println("stdout =====> ", stdout) out := t.GetStdout() - fmt.Sprintln("Output =====> ", stdout) + fmt.Println("Output =====> ", stdout) file.WriteString(stdout, out) //} From 78910eec048124973568c83c304905b084e1fbd8 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:13:29 +0800 Subject: [PATCH 22/70] Update task.go --- ibex/task.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 2366ff9c..b814408f 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -292,7 +292,7 @@ func (t *Task) start() { return } - //persistResult(t) + persistResult(t) go runProcess(t) } @@ -323,7 +323,7 @@ func runProcess(t *Task) { log.Printf("D! process of task[%d] done", t.Id) } - persistResult(t) + //persistResult(t) } func persistResult(t *Task) { @@ -336,12 +336,15 @@ func persistResult(t *Task) { fmt.Println("2") doneFlag := filepath.Join(metadir, fmt.Sprint(t.Id), fmt.Sprintf("%d.done", t.Clock)) - //{ - fmt.Println("stdout =====> ", stdout) - out := t.GetStdout() - fmt.Println("Output =====> ", stdout) - file.WriteString(stdout, out) - //} + for { + fmt.Println("stdout =====> ", stdout) + out := t.GetStdout() + fmt.Println("Output =====> ", out) + if out == "" { + break + } + file.WriteString(stdout, out) + } file.WriteString(stderr, t.GetStderr()) file.WriteString(doneFlag, t.GetStatus()) From 9b334f2d94d4a770f6dbfb05af873106a14d55ba Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:15:50 +0800 Subject: [PATCH 23/70] Update task.go --- ibex/task.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index b814408f..a159d79d 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -292,7 +292,7 @@ func (t *Task) start() { return } - persistResult(t) + go persistResult(t) go runProcess(t) } @@ -327,17 +327,12 @@ func runProcess(t *Task) { } func persistResult(t *Task) { - fmt.Println("Enter Output") metadir := config.Config.Ibex.MetaDir - fmt.Println("0") stdout := filepath.Join(metadir, fmt.Sprint(t.Id), "stdout") - fmt.Println("1") stderr := filepath.Join(metadir, fmt.Sprint(t.Id), "stderr") - fmt.Println("2") doneFlag := filepath.Join(metadir, fmt.Sprint(t.Id), fmt.Sprintf("%d.done", t.Clock)) for { - fmt.Println("stdout =====> ", stdout) out := t.GetStdout() fmt.Println("Output =====> ", out) if out == "" { From 4ee6755499c927974f9eb0be574d91686bf9fd7f Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:17:28 +0800 Subject: [PATCH 24/70] Update task.go --- ibex/task.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index a159d79d..1c832e94 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -292,7 +292,7 @@ func (t *Task) start() { return } - go persistResult(t) + //go persistResult(t) go runProcess(t) } @@ -323,7 +323,7 @@ func runProcess(t *Task) { log.Printf("D! process of task[%d] done", t.Id) } - //persistResult(t) + persistResult(t) } func persistResult(t *Task) { From 799c6d9d6bb7243089107244b640a63ca14c8731 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:20:43 +0800 Subject: [PATCH 25/70] ad --- ibex/cmd_nix.go | 2 +- ibex/task.go | 41 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/ibex/cmd_nix.go b/ibex/cmd_nix.go index 35549935..c3502470 100644 --- a/ibex/cmd_nix.go +++ b/ibex/cmd_nix.go @@ -9,7 +9,7 @@ import ( func CmdStart(cmd *exec.Cmd) error { cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} - return cmd.Start() + return cmd.Run() } func CmdKill(cmd *exec.Cmd) error { diff --git a/ibex/task.go b/ibex/task.go index 1c832e94..6b86c686 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -3,9 +3,12 @@ package ibex import ( + "bufio" "bytes" "fmt" + "io" "log" + "os" "os/exec" "os/user" "path" @@ -281,20 +284,52 @@ func (t *Task) start() { } } - cmd.Stdout = &t.Stdout + //cmd.Stdout = &t.Stdout cmd.Stderr = &t.Stderr cmd.Stdin = t.Stdin t.Cmd = cmd + var wg sync.WaitGroup + wg.Add(2) + //捕获标准输出 + stdout, err := cmd.StdoutPipe() + if err != nil { + fmt.Println("INFO:", err) + os.Exit(1) + } + readout := bufio.NewReader(stdout) + go func() { + defer wg.Done() + GetOutput(readout) + }() + err = CmdStart(cmd) if err != nil { log.Printf("E! cannot start cmd of task[%d]: %v", t.Id, err) return } - //go persistResult(t) + wg.Wait() + + //go runProcess(t) +} - go runProcess(t) +func GetOutput(reader *bufio.Reader) { + var sumOutput string //统计屏幕的全部输出内容 + outputBytes := make([]byte, 200) + for { + n, err := reader.Read(outputBytes) //获取屏幕的实时输出(并不是按照回车分割,所以要结合sumOutput) + if err != nil { + if err == io.EOF { + break + } + fmt.Println(err) + sumOutput += err.Error() + } + output := string(outputBytes[:n]) + fmt.Print(output) //输出屏幕内容 + sumOutput += output + } } func (t *Task) kill() { From 9994a5e738d061b52c49c779058bdddb15071bcb Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:28:46 +0800 Subject: [PATCH 26/70] Update task.go --- ibex/task.go | 61 +++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 6b86c686..6668aee3 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -289,19 +289,10 @@ func (t *Task) start() { cmd.Stdin = t.Stdin t.Cmd = cmd - var wg sync.WaitGroup + var wg *sync.WaitGroup wg.Add(2) - //捕获标准输出 - stdout, err := cmd.StdoutPipe() - if err != nil { - fmt.Println("INFO:", err) - os.Exit(1) - } - readout := bufio.NewReader(stdout) - go func() { - defer wg.Done() - GetOutput(readout) - }() + + runProcessRealtime(wg, cmd, t) err = CmdStart(cmd) if err != nil { @@ -314,7 +305,29 @@ func (t *Task) start() { //go runProcess(t) } -func GetOutput(reader *bufio.Reader) { +func (t *Task) kill() { + go killProcess(t) +} + +func runProcessRealtime(wg *sync.WaitGroup, cmd *exec.Cmd, t *Task) { + + //捕获标准输出 + stdout, err := cmd.StdoutPipe() + if err != nil { + fmt.Println("INFO:", err) + os.Exit(1) + } + readout := bufio.NewReader(stdout) + go func() { + defer wg.Done() + GetOutput(readout, t) + }() +} + +func GetOutput(reader *bufio.Reader, t *Task) { + t.SetAlive(true) + defer t.SetAlive(false) + var sumOutput string //统计屏幕的全部输出内容 outputBytes := make([]byte, 200) for { @@ -328,14 +341,12 @@ func GetOutput(reader *bufio.Reader) { } output := string(outputBytes[:n]) fmt.Print(output) //输出屏幕内容 + + persistResult(t, output) sumOutput += output } } -func (t *Task) kill() { - go killProcess(t) -} - func runProcess(t *Task) { t.SetAlive(true) defer t.SetAlive(false) @@ -358,24 +369,16 @@ func runProcess(t *Task) { log.Printf("D! process of task[%d] done", t.Id) } - persistResult(t) + //persistResult(t) } -func persistResult(t *Task) { +func persistResult(t *Task, msg string) { metadir := config.Config.Ibex.MetaDir stdout := filepath.Join(metadir, fmt.Sprint(t.Id), "stdout") stderr := filepath.Join(metadir, fmt.Sprint(t.Id), "stderr") doneFlag := filepath.Join(metadir, fmt.Sprint(t.Id), fmt.Sprintf("%d.done", t.Clock)) - for { - out := t.GetStdout() - fmt.Println("Output =====> ", out) - if out == "" { - break - } - file.WriteString(stdout, out) - } - + file.WriteString(stdout, msg) file.WriteString(stderr, t.GetStderr()) file.WriteString(doneFlag, t.GetStatus()) } @@ -395,5 +398,5 @@ func killProcess(t *Task) { log.Printf("D! process of task[%d] killed", t.Id) } - persistResult(t) + //persistResult(t) } From 8b65423fad6cdb627004b70905445195029d5da9 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:32:17 +0800 Subject: [PATCH 27/70] Update task.go --- ibex/task.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 6668aee3..e85bc843 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -289,10 +289,10 @@ func (t *Task) start() { cmd.Stdin = t.Stdin t.Cmd = cmd - var wg *sync.WaitGroup + var wg sync.WaitGroup wg.Add(2) - runProcessRealtime(wg, cmd, t) + runProcessRealtime(&wg, cmd, t) err = CmdStart(cmd) if err != nil { From 9467f9680fd3bf5ff6990d18b9f5f98907f07d9e Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:35:25 +0800 Subject: [PATCH 28/70] Update task.go --- ibex/task.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index e85bc843..e526b015 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -310,7 +310,6 @@ func (t *Task) kill() { } func runProcessRealtime(wg *sync.WaitGroup, cmd *exec.Cmd, t *Task) { - //捕获标准输出 stdout, err := cmd.StdoutPipe() if err != nil { @@ -340,7 +339,7 @@ func GetOutput(reader *bufio.Reader, t *Task) { sumOutput += err.Error() } output := string(outputBytes[:n]) - fmt.Print(output) //输出屏幕内容 + //fmt.Print(output) //输出屏幕内容 persistResult(t, output) sumOutput += output @@ -378,6 +377,7 @@ func persistResult(t *Task, msg string) { stderr := filepath.Join(metadir, fmt.Sprint(t.Id), "stderr") doneFlag := filepath.Join(metadir, fmt.Sprint(t.Id), fmt.Sprintf("%d.done", t.Clock)) + fmt.Println("Output ====> ", msg) file.WriteString(stdout, msg) file.WriteString(stderr, t.GetStderr()) file.WriteString(doneFlag, t.GetStatus()) From 1aba411e5e734e4cb5f3eebd90ded37836ff1c84 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:40:39 +0800 Subject: [PATCH 29/70] Update task.go --- ibex/task.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ibex/task.go b/ibex/task.go index e526b015..36c8adc4 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -344,6 +344,24 @@ func GetOutput(reader *bufio.Reader, t *Task) { persistResult(t, output) sumOutput += output } + + err := t.Cmd.Wait() + if err != nil { + if strings.Contains(err.Error(), "signal: killed") { + t.SetStatus("killed") + log.Printf("D! process of task[%d] killed", t.Id) + } else if strings.Contains(err.Error(), "signal: terminated") { + // kill children process manually + t.SetStatus("killed") + log.Printf("D! process of task[%d] terminated", t.Id) + } else { + t.SetStatus("failed") + log.Printf("D! process of task[%d] return error: %v", t.Id, err) + } + } else { + t.SetStatus("success") + log.Printf("D! process of task[%d] done", t.Id) + } } func runProcess(t *Task) { From 483582b1526c31162efe5be2655ad7da3e36efe8 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:45:07 +0800 Subject: [PATCH 30/70] Update task.go --- ibex/task.go | 1 + 1 file changed, 1 insertion(+) diff --git a/ibex/task.go b/ibex/task.go index 36c8adc4..6fb3a4eb 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -346,6 +346,7 @@ func GetOutput(reader *bufio.Reader, t *Task) { } err := t.Cmd.Wait() + fmt.Println("xxxx", err) if err != nil { if strings.Contains(err.Error(), "signal: killed") { t.SetStatus("killed") From eb58a792a313582334930b36cb23eed42731f51a Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:46:55 +0800 Subject: [PATCH 31/70] Update task.go --- ibex/task.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ibex/task.go b/ibex/task.go index 6fb3a4eb..4a5c5c73 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -363,6 +363,8 @@ func GetOutput(reader *bufio.Reader, t *Task) { t.SetStatus("success") log.Printf("D! process of task[%d] done", t.Id) } + + persistResult(t, sumOutput) } func runProcess(t *Task) { From 8a094344679afd2e3a4d079b7346826ff5e26b44 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:49:30 +0800 Subject: [PATCH 32/70] Update cmd_nix.go --- ibex/cmd_nix.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibex/cmd_nix.go b/ibex/cmd_nix.go index c3502470..35549935 100644 --- a/ibex/cmd_nix.go +++ b/ibex/cmd_nix.go @@ -9,7 +9,7 @@ import ( func CmdStart(cmd *exec.Cmd) error { cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} - return cmd.Run() + return cmd.Start() } func CmdKill(cmd *exec.Cmd) error { From 1ba127d97ab091bc5871a10dbd64ebff2640944f Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:52:18 +0800 Subject: [PATCH 33/70] Update task.go --- ibex/task.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibex/task.go b/ibex/task.go index 4a5c5c73..25754c0c 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -290,7 +290,7 @@ func (t *Task) start() { t.Cmd = cmd var wg sync.WaitGroup - wg.Add(2) + wg.Add(1) runProcessRealtime(&wg, cmd, t) From dc774366bebb5312fc0d6790b594d6f804fc41b4 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 11:53:34 +0800 Subject: [PATCH 34/70] Update task.go --- ibex/task.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 25754c0c..abc17931 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -292,9 +292,9 @@ func (t *Task) start() { var wg sync.WaitGroup wg.Add(1) - runProcessRealtime(&wg, cmd, t) - err = CmdStart(cmd) + + runProcessRealtime(&wg, cmd, t) if err != nil { log.Printf("E! cannot start cmd of task[%d]: %v", t.Id, err) return From 531e1a888a852351e8cb93a0cf62c3d4d13e625b Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 13:37:50 +0800 Subject: [PATCH 35/70] Update task.go --- ibex/task.go | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index abc17931..6a601582 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -289,19 +289,15 @@ func (t *Task) start() { cmd.Stdin = t.Stdin t.Cmd = cmd - var wg sync.WaitGroup - wg.Add(1) + runProcessRealtime(cmd, t) err = CmdStart(cmd) - runProcessRealtime(&wg, cmd, t) if err != nil { log.Printf("E! cannot start cmd of task[%d]: %v", t.Id, err) return } - wg.Wait() - //go runProcess(t) } @@ -309,7 +305,7 @@ func (t *Task) kill() { go killProcess(t) } -func runProcessRealtime(wg *sync.WaitGroup, cmd *exec.Cmd, t *Task) { +func runProcessRealtime(cmd *exec.Cmd, t *Task) { //捕获标准输出 stdout, err := cmd.StdoutPipe() if err != nil { @@ -317,10 +313,7 @@ func runProcessRealtime(wg *sync.WaitGroup, cmd *exec.Cmd, t *Task) { os.Exit(1) } readout := bufio.NewReader(stdout) - go func() { - defer wg.Done() - GetOutput(readout, t) - }() + GetOutput(readout, t) } func GetOutput(reader *bufio.Reader, t *Task) { @@ -398,8 +391,8 @@ func persistResult(t *Task, msg string) { stderr := filepath.Join(metadir, fmt.Sprint(t.Id), "stderr") doneFlag := filepath.Join(metadir, fmt.Sprint(t.Id), fmt.Sprintf("%d.done", t.Clock)) - fmt.Println("Output ====> ", msg) - file.WriteString(stdout, msg) + fmt.Println("Output ====> ", t.GetStdout()) + file.WriteString(stdout, t.GetStdout()) file.WriteString(stderr, t.GetStderr()) file.WriteString(doneFlag, t.GetStatus()) } From d788b44d519db306e15a20861ca99798ce92f768 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 13:39:06 +0800 Subject: [PATCH 36/70] Update task.go --- ibex/task.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibex/task.go b/ibex/task.go index 6a601582..74dd1097 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -289,7 +289,7 @@ func (t *Task) start() { cmd.Stdin = t.Stdin t.Cmd = cmd - runProcessRealtime(cmd, t) + go runProcessRealtime(cmd, t) err = CmdStart(cmd) From 1d6875515acc604c6d8cf46a82ff2280b54adc1b Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 13:41:35 +0800 Subject: [PATCH 37/70] Update task.go --- ibex/task.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 74dd1097..09deb70e 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -284,13 +284,11 @@ func (t *Task) start() { } } - //cmd.Stdout = &t.Stdout + cmd.Stdout = &t.Stdout cmd.Stderr = &t.Stderr cmd.Stdin = t.Stdin t.Cmd = cmd - go runProcessRealtime(cmd, t) - err = CmdStart(cmd) if err != nil { @@ -298,7 +296,7 @@ func (t *Task) start() { return } - //go runProcess(t) + go runProcess(t) } func (t *Task) kill() { @@ -334,7 +332,7 @@ func GetOutput(reader *bufio.Reader, t *Task) { output := string(outputBytes[:n]) //fmt.Print(output) //输出屏幕内容 - persistResult(t, output) + persistResult(t) sumOutput += output } @@ -357,7 +355,6 @@ func GetOutput(reader *bufio.Reader, t *Task) { log.Printf("D! process of task[%d] done", t.Id) } - persistResult(t, sumOutput) } func runProcess(t *Task) { @@ -382,10 +379,10 @@ func runProcess(t *Task) { log.Printf("D! process of task[%d] done", t.Id) } - //persistResult(t) + persistResult(t) } -func persistResult(t *Task, msg string) { +func persistResult(t *Task) { metadir := config.Config.Ibex.MetaDir stdout := filepath.Join(metadir, fmt.Sprint(t.Id), "stdout") stderr := filepath.Join(metadir, fmt.Sprint(t.Id), "stderr") @@ -412,5 +409,5 @@ func killProcess(t *Task) { log.Printf("D! process of task[%d] killed", t.Id) } - //persistResult(t) + persistResult(t) } From 0a45acc3be2085c48bd29b42695f276c06961a6d Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 13:50:59 +0800 Subject: [PATCH 38/70] Update task.go --- ibex/task.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 09deb70e..5a7b5295 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -284,11 +284,17 @@ func (t *Task) start() { } } - cmd.Stdout = &t.Stdout + //cmd.Stdout = &t.Stdout cmd.Stderr = &t.Stderr cmd.Stdin = t.Stdin t.Cmd = cmd + stdout, err := t.Cmd.StdoutPipe() + + if err != nil { + fmt.Println(err) + } + err = CmdStart(cmd) if err != nil { @@ -296,7 +302,18 @@ func (t *Task) start() { return } - go runProcess(t) + reader := bufio.NewReader(stdout) + //实时循环读取输出流中的一行内容 + for { + line, err2 := reader.ReadString('\n') + if err2 != nil || io.EOF == err2 { + break + } + fmt.Println(line) + } + t.Cmd.Wait() + + //go runProcess(t) } func (t *Task) kill() { @@ -337,7 +354,6 @@ func GetOutput(reader *bufio.Reader, t *Task) { } err := t.Cmd.Wait() - fmt.Println("xxxx", err) if err != nil { if strings.Contains(err.Error(), "signal: killed") { t.SetStatus("killed") From 7998e14b40d1a270211f14e27efc8147eee6aeae Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 13:53:05 +0800 Subject: [PATCH 39/70] Update task.go --- ibex/task.go | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 5a7b5295..b6673788 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -302,16 +302,22 @@ func (t *Task) start() { return } - reader := bufio.NewReader(stdout) - //实时循环读取输出流中的一行内容 - for { - line, err2 := reader.ReadString('\n') - if err2 != nil || io.EOF == err2 { - break + go func() { + reader := bufio.NewReader(stdout) + //实时循环读取输出流中的一行内容 + for { + line, err2 := reader.ReadString('\n') + if err2 != nil || io.EOF == err2 { + break + } + fmt.Println(line) } - fmt.Println(line) - } - t.Cmd.Wait() + err := t.Cmd.Wait() + + if err != nil { + fmt.Println(err) + } + }() //go runProcess(t) } From edfa0dc0bac809de21c30d510f244ce72358b722 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 13:57:22 +0800 Subject: [PATCH 40/70] Update task.go --- ibex/task.go | 81 +++++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 36 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index b6673788..18002ea5 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -8,7 +8,6 @@ import ( "fmt" "io" "log" - "os" "os/exec" "os/user" "path" @@ -303,6 +302,9 @@ func (t *Task) start() { } go func() { + t.SetAlive(true) + defer t.SetAlive(false) + reader := bufio.NewReader(stdout) //实时循环读取输出流中的一行内容 for { @@ -313,28 +315,60 @@ func (t *Task) start() { fmt.Println(line) } err := t.Cmd.Wait() - if err != nil { - fmt.Println(err) + if strings.Contains(err.Error(), "signal: killed") { + t.SetStatus("killed") + log.Printf("D! process of task[%d] killed", t.Id) + } else if strings.Contains(err.Error(), "signal: terminated") { + // kill children process manually + t.SetStatus("killed") + log.Printf("D! process of task[%d] terminated", t.Id) + } else { + t.SetStatus("failed") + log.Printf("D! process of task[%d] return error: %v", t.Id, err) + } + } else { + t.SetStatus("success") + log.Printf("D! process of task[%d] done", t.Id) } + + persistResult(t) }() //go runProcess(t) } +func runProcess(t *Task) { + t.SetAlive(true) + defer t.SetAlive(false) + + err := t.Cmd.Wait() + if err != nil { + if strings.Contains(err.Error(), "signal: killed") { + t.SetStatus("killed") + log.Printf("D! process of task[%d] killed", t.Id) + } else if strings.Contains(err.Error(), "signal: terminated") { + // kill children process manually + t.SetStatus("killed") + log.Printf("D! process of task[%d] terminated", t.Id) + } else { + t.SetStatus("failed") + log.Printf("D! process of task[%d] return error: %v", t.Id, err) + } + } else { + t.SetStatus("success") + log.Printf("D! process of task[%d] done", t.Id) + } + + persistResult(t) +} + func (t *Task) kill() { go killProcess(t) } func runProcessRealtime(cmd *exec.Cmd, t *Task) { - //捕获标准输出 - stdout, err := cmd.StdoutPipe() - if err != nil { - fmt.Println("INFO:", err) - os.Exit(1) - } - readout := bufio.NewReader(stdout) - GetOutput(readout, t) + } func GetOutput(reader *bufio.Reader, t *Task) { @@ -379,31 +413,6 @@ func GetOutput(reader *bufio.Reader, t *Task) { } -func runProcess(t *Task) { - t.SetAlive(true) - defer t.SetAlive(false) - - err := t.Cmd.Wait() - if err != nil { - if strings.Contains(err.Error(), "signal: killed") { - t.SetStatus("killed") - log.Printf("D! process of task[%d] killed", t.Id) - } else if strings.Contains(err.Error(), "signal: terminated") { - // kill children process manually - t.SetStatus("killed") - log.Printf("D! process of task[%d] terminated", t.Id) - } else { - t.SetStatus("failed") - log.Printf("D! process of task[%d] return error: %v", t.Id, err) - } - } else { - t.SetStatus("success") - log.Printf("D! process of task[%d] done", t.Id) - } - - persistResult(t) -} - func persistResult(t *Task) { metadir := config.Config.Ibex.MetaDir stdout := filepath.Join(metadir, fmt.Sprint(t.Id), "stdout") From a354a420407b88f43da21a7910efb7b8e751b472 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 14:35:57 +0800 Subject: [PATCH 41/70] Update task.go --- ibex/task.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 18002ea5..23e4d6a9 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -312,7 +312,8 @@ func (t *Task) start() { if err2 != nil || io.EOF == err2 { break } - fmt.Println(line) + t.Stdout.WriteString(line) + fmt.Println("=====>", t.GetStdout()) } err := t.Cmd.Wait() if err != nil { @@ -419,7 +420,6 @@ func persistResult(t *Task) { stderr := filepath.Join(metadir, fmt.Sprint(t.Id), "stderr") doneFlag := filepath.Join(metadir, fmt.Sprint(t.Id), fmt.Sprintf("%d.done", t.Clock)) - fmt.Println("Output ====> ", t.GetStdout()) file.WriteString(stdout, t.GetStdout()) file.WriteString(stderr, t.GetStderr()) file.WriteString(doneFlag, t.GetStatus()) From a6bb245d2752720d1effe808e80fd23502108739 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 14:39:05 +0800 Subject: [PATCH 42/70] Update task.go --- ibex/task.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ibex/task.go b/ibex/task.go index 23e4d6a9..d7a859f3 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -313,8 +313,10 @@ func (t *Task) start() { break } t.Stdout.WriteString(line) + persistResult(t) fmt.Println("=====>", t.GetStdout()) } + err := t.Cmd.Wait() if err != nil { if strings.Contains(err.Error(), "signal: killed") { From 425078817083c38f08acfb12f5ec9b4c8805c3be Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 18:24:35 +0800 Subject: [PATCH 43/70] Update tasks.go --- ibex/tasks.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ibex/tasks.go b/ibex/tasks.go index 954e07fc..9058a060 100644 --- a/ibex/tasks.go +++ b/ibex/tasks.go @@ -3,6 +3,7 @@ package ibex import ( + "fmt" "log" "flashcat.cloud/categraf/ibex/types" @@ -25,9 +26,13 @@ func (lt *LocalTasksT) ReportTasks() []types.ReportTask { continue } + fmt.Println("starting report") + rt.Stdout = t.GetStdout() rt.Stderr = t.GetStderr() + fmt.Println(t.GetStdout()) + stdoutLen := len(rt.Stdout) stderrLen := len(rt.Stderr) From 0ab829f8425c5badeb6c123c10cecc5012ad87f7 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 18:29:39 +0800 Subject: [PATCH 44/70] s --- ibex/heartbeat.go | 3 ++- ibex/tasks.go | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ibex/heartbeat.go b/ibex/heartbeat.go index abe28b04..eef5cb68 100644 --- a/ibex/heartbeat.go +++ b/ibex/heartbeat.go @@ -4,6 +4,7 @@ package ibex import ( "context" + "fmt" "log" "os" "os/signal" @@ -34,7 +35,7 @@ func heartbeat() { Ident: ident, ReportTasks: Locals.ReportTasks(), } - + fmt.Println("heartbeat") var resp types.ReportResponse err := client.GetCli().Call("Server.Report", req, &resp) diff --git a/ibex/tasks.go b/ibex/tasks.go index 9058a060..e37c59e8 100644 --- a/ibex/tasks.go +++ b/ibex/tasks.go @@ -31,8 +31,6 @@ func (lt *LocalTasksT) ReportTasks() []types.ReportTask { rt.Stdout = t.GetStdout() rt.Stderr = t.GetStderr() - fmt.Println(t.GetStdout()) - stdoutLen := len(rt.Stdout) stderrLen := len(rt.Stderr) From f03e28e3fdde03645ccd478b693a7b9754b38d3f Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 18:32:35 +0800 Subject: [PATCH 45/70] Update tasks.go --- ibex/tasks.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibex/tasks.go b/ibex/tasks.go index e37c59e8..466791a6 100644 --- a/ibex/tasks.go +++ b/ibex/tasks.go @@ -21,7 +21,7 @@ func (lt *LocalTasksT) ReportTasks() []types.ReportTask { rt := types.ReportTask{Id: id, Clock: t.Clock} rt.Status = t.GetStatus() - if rt.Status == "running" || rt.Status == "killing" { + if rt.Status == "killing" { // intermediate state continue } From 686b322621de505b02037b17740295c80520b1a7 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 18:35:35 +0800 Subject: [PATCH 46/70] a --- ibex/heartbeat.go | 3 +-- ibex/tasks.go | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ibex/heartbeat.go b/ibex/heartbeat.go index eef5cb68..abe28b04 100644 --- a/ibex/heartbeat.go +++ b/ibex/heartbeat.go @@ -4,7 +4,6 @@ package ibex import ( "context" - "fmt" "log" "os" "os/signal" @@ -35,7 +34,7 @@ func heartbeat() { Ident: ident, ReportTasks: Locals.ReportTasks(), } - fmt.Println("heartbeat") + var resp types.ReportResponse err := client.GetCli().Call("Server.Report", req, &resp) diff --git a/ibex/tasks.go b/ibex/tasks.go index 466791a6..28532781 100644 --- a/ibex/tasks.go +++ b/ibex/tasks.go @@ -26,7 +26,9 @@ func (lt *LocalTasksT) ReportTasks() []types.ReportTask { continue } - fmt.Println("starting report") + if rt.Status == "running" { + fmt.Println("starting report: ===> ", t.GetStdout()) + } rt.Stdout = t.GetStdout() rt.Stderr = t.GetStderr() From 05ad2e53f79da39ad28e8107179094bd1ee566e1 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 23:16:51 +0800 Subject: [PATCH 47/70] Update heartbeat.go --- ibex/heartbeat.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ibex/heartbeat.go b/ibex/heartbeat.go index abe28b04..59a36e12 100644 --- a/ibex/heartbeat.go +++ b/ibex/heartbeat.go @@ -4,6 +4,7 @@ package ibex import ( "context" + "fmt" "log" "os" "os/signal" @@ -36,6 +37,7 @@ func heartbeat() { } var resp types.ReportResponse + fmt.Println(resp) err := client.GetCli().Call("Server.Report", req, &resp) if err != nil { From b471dff5b3d96e4c5a940cae557112294d25aec7 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 23:23:23 +0800 Subject: [PATCH 48/70] aa --- ibex/heartbeat.go | 2 +- ibex/task.go | 4 ++-- ibex/tasks.go | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/ibex/heartbeat.go b/ibex/heartbeat.go index 59a36e12..20e72ec6 100644 --- a/ibex/heartbeat.go +++ b/ibex/heartbeat.go @@ -37,7 +37,7 @@ func heartbeat() { } var resp types.ReportResponse - fmt.Println(resp) + fmt.Println(req) err := client.GetCli().Call("Server.Report", req, &resp) if err != nil { diff --git a/ibex/task.go b/ibex/task.go index d7a859f3..73b84c34 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -314,7 +314,7 @@ func (t *Task) start() { } t.Stdout.WriteString(line) persistResult(t) - fmt.Println("=====>", t.GetStdout()) + //fmt.Println("=====>", t.GetStdout()) } err := t.Cmd.Wait() @@ -335,7 +335,7 @@ func (t *Task) start() { log.Printf("D! process of task[%d] done", t.Id) } - persistResult(t) + //persistResult(t) }() //go runProcess(t) diff --git a/ibex/tasks.go b/ibex/tasks.go index 28532781..e6ad3923 100644 --- a/ibex/tasks.go +++ b/ibex/tasks.go @@ -3,7 +3,6 @@ package ibex import ( - "fmt" "log" "flashcat.cloud/categraf/ibex/types" @@ -27,7 +26,7 @@ func (lt *LocalTasksT) ReportTasks() []types.ReportTask { } if rt.Status == "running" { - fmt.Println("starting report: ===> ", t.GetStdout()) + //fmt.Println("starting report: ===> ", t.GetStdout()) } rt.Stdout = t.GetStdout() From 13325da4bc4755fb36539758cd6fbdd86bb21ef6 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 23:31:30 +0800 Subject: [PATCH 49/70] Update tasks.go --- ibex/tasks.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ibex/tasks.go b/ibex/tasks.go index e6ad3923..d874958d 100644 --- a/ibex/tasks.go +++ b/ibex/tasks.go @@ -20,14 +20,14 @@ func (lt *LocalTasksT) ReportTasks() []types.ReportTask { rt := types.ReportTask{Id: id, Clock: t.Clock} rt.Status = t.GetStatus() - if rt.Status == "killing" { + if rt.Status == "killing" || rt.Status == "running" { // intermediate state continue } - if rt.Status == "running" { - //fmt.Println("starting report: ===> ", t.GetStdout()) - } + //if rt.Status == "running" { + // //fmt.Println("starting report: ===> ", t.GetStdout()) + //} rt.Stdout = t.GetStdout() rt.Stderr = t.GetStderr() From f4b568f42022416b5d1ca15db1dbba8a0d19daeb Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 23:35:55 +0800 Subject: [PATCH 50/70] Update tasks.go --- ibex/tasks.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ibex/tasks.go b/ibex/tasks.go index d874958d..fbfa4667 100644 --- a/ibex/tasks.go +++ b/ibex/tasks.go @@ -3,6 +3,7 @@ package ibex import ( + "fmt" "log" "flashcat.cloud/categraf/ibex/types" @@ -20,6 +21,7 @@ func (lt *LocalTasksT) ReportTasks() []types.ReportTask { rt := types.ReportTask{Id: id, Clock: t.Clock} rt.Status = t.GetStatus() + fmt.Println(rt.Status) if rt.Status == "killing" || rt.Status == "running" { // intermediate state continue From aae5781fa4a6b4a7d039fe7554a1784337e3f50c Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 23:38:00 +0800 Subject: [PATCH 51/70] Update tasks.go --- ibex/tasks.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibex/tasks.go b/ibex/tasks.go index fbfa4667..dd38bffe 100644 --- a/ibex/tasks.go +++ b/ibex/tasks.go @@ -22,7 +22,7 @@ func (lt *LocalTasksT) ReportTasks() []types.ReportTask { rt.Status = t.GetStatus() fmt.Println(rt.Status) - if rt.Status == "killing" || rt.Status == "running" { + if rt.Status == "killing" { // intermediate state continue } From 7d7b639d02239853e2913cbea3cb69da8ee19710 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 23:42:01 +0800 Subject: [PATCH 52/70] Update heartbeat.go --- ibex/heartbeat.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ibex/heartbeat.go b/ibex/heartbeat.go index 20e72ec6..bfea6291 100644 --- a/ibex/heartbeat.go +++ b/ibex/heartbeat.go @@ -37,9 +37,9 @@ func heartbeat() { } var resp types.ReportResponse - fmt.Println(req) - err := client.GetCli().Call("Server.Report", req, &resp) + err := client.GetCli().Call("Server.Report", req, &resp) + fmt.Println(resp) if err != nil { log.Println("E! rpc call Server.Report fail:", err) client.CloseCli() From b1f5913b7bdb123720c38c00c7082e6752e3a5ee Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 23:44:23 +0800 Subject: [PATCH 53/70] Update tasks.go --- ibex/tasks.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ibex/tasks.go b/ibex/tasks.go index dd38bffe..bba3f3e1 100644 --- a/ibex/tasks.go +++ b/ibex/tasks.go @@ -21,7 +21,6 @@ func (lt *LocalTasksT) ReportTasks() []types.ReportTask { rt := types.ReportTask{Id: id, Clock: t.Clock} rt.Status = t.GetStatus() - fmt.Println(rt.Status) if rt.Status == "killing" { // intermediate state continue @@ -37,6 +36,8 @@ func (lt *LocalTasksT) ReportTasks() []types.ReportTask { stdoutLen := len(rt.Stdout) stderrLen := len(rt.Stderr) + fmt.Println(stdoutLen) + // 输出太长的话,截断,要不然把数据库撑爆了 if stdoutLen > 65535 { start := stdoutLen - 65535 From 33b5cbe2cc33c4f4eb6783f1c60835ef1918cbe9 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 23:48:28 +0800 Subject: [PATCH 54/70] Update tasks.go --- ibex/tasks.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ibex/tasks.go b/ibex/tasks.go index bba3f3e1..9e345880 100644 --- a/ibex/tasks.go +++ b/ibex/tasks.go @@ -21,10 +21,10 @@ func (lt *LocalTasksT) ReportTasks() []types.ReportTask { rt := types.ReportTask{Id: id, Clock: t.Clock} rt.Status = t.GetStatus() - if rt.Status == "killing" { - // intermediate state - continue - } + //if rt.Status == "killing" { + // // intermediate state + // continue + //} //if rt.Status == "running" { // //fmt.Println("starting report: ===> ", t.GetStdout()) @@ -37,6 +37,15 @@ func (lt *LocalTasksT) ReportTasks() []types.ReportTask { stderrLen := len(rt.Stderr) fmt.Println(stdoutLen) + if rt.Status == "killing" { + // intermediate state + continue + } + + if rt.Status == "running" && stdoutLen != 10 { + // intermediate state + continue + } // 输出太长的话,截断,要不然把数据库撑爆了 if stdoutLen > 65535 { From e729a6abbebbed9ec7f111dc216b3fec7b4ec6ef Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 20 Jun 2024 23:54:43 +0800 Subject: [PATCH 55/70] a --- ibex/heartbeat.go | 2 +- ibex/tasks.go | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/ibex/heartbeat.go b/ibex/heartbeat.go index bfea6291..400081e4 100644 --- a/ibex/heartbeat.go +++ b/ibex/heartbeat.go @@ -39,7 +39,7 @@ func heartbeat() { var resp types.ReportResponse err := client.GetCli().Call("Server.Report", req, &resp) - fmt.Println(resp) + fmt.Println(req, resp) if err != nil { log.Println("E! rpc call Server.Report fail:", err) client.CloseCli() diff --git a/ibex/tasks.go b/ibex/tasks.go index 9e345880..c8faa447 100644 --- a/ibex/tasks.go +++ b/ibex/tasks.go @@ -21,10 +21,10 @@ func (lt *LocalTasksT) ReportTasks() []types.ReportTask { rt := types.ReportTask{Id: id, Clock: t.Clock} rt.Status = t.GetStatus() - //if rt.Status == "killing" { - // // intermediate state - // continue - //} + if rt.Status == "killing" { + // intermediate state + continue + } //if rt.Status == "running" { // //fmt.Println("starting report: ===> ", t.GetStdout()) @@ -42,11 +42,6 @@ func (lt *LocalTasksT) ReportTasks() []types.ReportTask { continue } - if rt.Status == "running" && stdoutLen != 10 { - // intermediate state - continue - } - // 输出太长的话,截断,要不然把数据库撑爆了 if stdoutLen > 65535 { start := stdoutLen - 65535 From 0142811e90ed9e178a717f889dcdbe180562c3bd Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Fri, 21 Jun 2024 11:40:49 +0800 Subject: [PATCH 56/70] realtime report --- ibex/heartbeat.go | 3 +- ibex/task.go | 91 +++++------------------------------------------ ibex/tasks.go | 11 ------ 3 files changed, 9 insertions(+), 96 deletions(-) diff --git a/ibex/heartbeat.go b/ibex/heartbeat.go index 400081e4..477e9b68 100644 --- a/ibex/heartbeat.go +++ b/ibex/heartbeat.go @@ -4,7 +4,6 @@ package ibex import ( "context" - "fmt" "log" "os" "os/signal" @@ -39,7 +38,7 @@ func heartbeat() { var resp types.ReportResponse err := client.GetCli().Call("Server.Report", req, &resp) - fmt.Println(req, resp) + if err != nil { log.Println("E! rpc call Server.Report fail:", err) client.CloseCli() diff --git a/ibex/task.go b/ibex/task.go index 73b84c34..837b610e 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -283,7 +283,6 @@ func (t *Task) start() { } } - //cmd.Stdout = &t.Stdout cmd.Stderr = &t.Stderr cmd.Stdin = t.Stdin t.Cmd = cmd @@ -301,99 +300,26 @@ func (t *Task) start() { return } - go func() { - t.SetAlive(true) - defer t.SetAlive(false) - - reader := bufio.NewReader(stdout) - //实时循环读取输出流中的一行内容 - for { - line, err2 := reader.ReadString('\n') - if err2 != nil || io.EOF == err2 { - break - } - t.Stdout.WriteString(line) - persistResult(t) - //fmt.Println("=====>", t.GetStdout()) - } - - err := t.Cmd.Wait() - if err != nil { - if strings.Contains(err.Error(), "signal: killed") { - t.SetStatus("killed") - log.Printf("D! process of task[%d] killed", t.Id) - } else if strings.Contains(err.Error(), "signal: terminated") { - // kill children process manually - t.SetStatus("killed") - log.Printf("D! process of task[%d] terminated", t.Id) - } else { - t.SetStatus("failed") - log.Printf("D! process of task[%d] return error: %v", t.Id, err) - } - } else { - t.SetStatus("success") - log.Printf("D! process of task[%d] done", t.Id) - } - - //persistResult(t) - }() - - //go runProcess(t) -} - -func runProcess(t *Task) { - t.SetAlive(true) - defer t.SetAlive(false) - - err := t.Cmd.Wait() - if err != nil { - if strings.Contains(err.Error(), "signal: killed") { - t.SetStatus("killed") - log.Printf("D! process of task[%d] killed", t.Id) - } else if strings.Contains(err.Error(), "signal: terminated") { - // kill children process manually - t.SetStatus("killed") - log.Printf("D! process of task[%d] terminated", t.Id) - } else { - t.SetStatus("failed") - log.Printf("D! process of task[%d] return error: %v", t.Id, err) - } - } else { - t.SetStatus("success") - log.Printf("D! process of task[%d] done", t.Id) - } - - persistResult(t) + go runProcessRealtime(stdout, t) } func (t *Task) kill() { go killProcess(t) } -func runProcessRealtime(cmd *exec.Cmd, t *Task) { - -} - -func GetOutput(reader *bufio.Reader, t *Task) { +func runProcessRealtime(stdout io.ReadCloser, t *Task) { t.SetAlive(true) defer t.SetAlive(false) - var sumOutput string //统计屏幕的全部输出内容 - outputBytes := make([]byte, 200) + reader := bufio.NewReader(stdout) + //实时循环读取输出流中的一行内容 for { - n, err := reader.Read(outputBytes) //获取屏幕的实时输出(并不是按照回车分割,所以要结合sumOutput) - if err != nil { - if err == io.EOF { - break - } - fmt.Println(err) - sumOutput += err.Error() + line, err2 := reader.ReadString('\n') + if err2 != nil || io.EOF == err2 { + break } - output := string(outputBytes[:n]) - //fmt.Print(output) //输出屏幕内容 - + t.Stdout.WriteString(line) persistResult(t) - sumOutput += output } err := t.Cmd.Wait() @@ -413,7 +339,6 @@ func GetOutput(reader *bufio.Reader, t *Task) { t.SetStatus("success") log.Printf("D! process of task[%d] done", t.Id) } - } func persistResult(t *Task) { diff --git a/ibex/tasks.go b/ibex/tasks.go index c8faa447..d39dc692 100644 --- a/ibex/tasks.go +++ b/ibex/tasks.go @@ -3,7 +3,6 @@ package ibex import ( - "fmt" "log" "flashcat.cloud/categraf/ibex/types" @@ -26,22 +25,12 @@ func (lt *LocalTasksT) ReportTasks() []types.ReportTask { continue } - //if rt.Status == "running" { - // //fmt.Println("starting report: ===> ", t.GetStdout()) - //} - rt.Stdout = t.GetStdout() rt.Stderr = t.GetStderr() stdoutLen := len(rt.Stdout) stderrLen := len(rt.Stderr) - fmt.Println(stdoutLen) - if rt.Status == "killing" { - // intermediate state - continue - } - // 输出太长的话,截断,要不然把数据库撑爆了 if stdoutLen > 65535 { start := stdoutLen - 65535 From c06af9635d1a06a1cc8d7d3e7cd7e32569b33826 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Fri, 21 Jun 2024 14:22:10 +0800 Subject: [PATCH 57/70] Update task.go --- ibex/task.go | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 837b610e..d92a9089 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -283,14 +283,18 @@ func (t *Task) start() { } } - cmd.Stderr = &t.Stderr cmd.Stdin = t.Stdin t.Cmd = cmd stdout, err := t.Cmd.StdoutPipe() + if err != nil { + log.Printf("E! cannot read ouput of task[%d]: %v", t.Id, err) + } + + stderr, err := t.Cmd.StderrPipe() if err != nil { - fmt.Println(err) + log.Printf("E! cannot read err of task[%d]: %v", t.Id, err) } err = CmdStart(cmd) @@ -300,14 +304,14 @@ func (t *Task) start() { return } - go runProcessRealtime(stdout, t) + go runProcessRealtime(stdout, stderr, t) } func (t *Task) kill() { go killProcess(t) } -func runProcessRealtime(stdout io.ReadCloser, t *Task) { +func runProcessRealtime(stdout io.ReadCloser, stderr io.ReadCloser, t *Task) { t.SetAlive(true) defer t.SetAlive(false) @@ -322,6 +326,17 @@ func runProcessRealtime(stdout io.ReadCloser, t *Task) { persistResult(t) } + errReader := bufio.NewReader(stderr) + //实时循环读取输出流中的一行内容 + for { + line, err2 := errReader.ReadString('\n') + if err2 != nil || io.EOF == err2 { + break + } + t.Stderr.WriteString(line) + persistResult(t) + } + err := t.Cmd.Wait() if err != nil { if strings.Contains(err.Error(), "signal: killed") { From e1fd24a35c77b7bdb9d601c98a0cfa29a0b3e079 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Fri, 21 Jun 2024 14:35:33 +0800 Subject: [PATCH 58/70] Update task.go --- ibex/task.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ibex/task.go b/ibex/task.go index d92a9089..0a676413 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -323,6 +323,8 @@ func runProcessRealtime(stdout io.ReadCloser, stderr io.ReadCloser, t *Task) { break } t.Stdout.WriteString(line) + + fmt.Println("success", line) persistResult(t) } @@ -334,6 +336,7 @@ func runProcessRealtime(stdout io.ReadCloser, stderr io.ReadCloser, t *Task) { break } t.Stderr.WriteString(line) + fmt.Println("error", line) persistResult(t) } From afeaca8588d62b29bfa8a000410b3bb580afce1c Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Fri, 21 Jun 2024 14:39:48 +0800 Subject: [PATCH 59/70] Update task.go --- ibex/task.go | 52 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 0a676413..b50f1e92 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -315,30 +315,44 @@ func runProcessRealtime(stdout io.ReadCloser, stderr io.ReadCloser, t *Task) { t.SetAlive(true) defer t.SetAlive(false) + var wg sync.WaitGroup + + wg.Add(2) + reader := bufio.NewReader(stdout) - //实时循环读取输出流中的一行内容 - for { - line, err2 := reader.ReadString('\n') - if err2 != nil || io.EOF == err2 { - break - } - t.Stdout.WriteString(line) - fmt.Println("success", line) - persistResult(t) - } + go func() { + defer wg.Done() + //实时循环读取输出流中的一行内容 + for { + line, err2 := reader.ReadString('\n') + if err2 != nil || io.EOF == err2 { + break + } + t.Stdout.WriteString(line) + + fmt.Println("success", line) + persistResult(t) + } + }() errReader := bufio.NewReader(stderr) - //实时循环读取输出流中的一行内容 - for { - line, err2 := errReader.ReadString('\n') - if err2 != nil || io.EOF == err2 { - break + + go func() { + defer wg.Done() + //实时循环读取输出流中的一行内容 + for { + line, err2 := errReader.ReadString('\n') + if err2 != nil || io.EOF == err2 { + break + } + t.Stderr.WriteString(line) + fmt.Println("error", line) + persistResult(t) } - t.Stderr.WriteString(line) - fmt.Println("error", line) - persistResult(t) - } + }() + + wg.Wait() err := t.Cmd.Wait() if err != nil { From faaa5b431e5a341b464647f4026f0a3e504ec02e Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Fri, 21 Jun 2024 14:46:03 +0800 Subject: [PATCH 60/70] Update task.go --- ibex/task.go | 50 +++++++++++++++++++------------------------------- 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index b50f1e92..001676b6 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -315,44 +315,32 @@ func runProcessRealtime(stdout io.ReadCloser, stderr io.ReadCloser, t *Task) { t.SetAlive(true) defer t.SetAlive(false) - var wg sync.WaitGroup - - wg.Add(2) - reader := bufio.NewReader(stdout) - go func() { - defer wg.Done() - //实时循环读取输出流中的一行内容 - for { - line, err2 := reader.ReadString('\n') - if err2 != nil || io.EOF == err2 { - break - } - t.Stdout.WriteString(line) - - fmt.Println("success", line) - persistResult(t) + //实时循环读取输出流中的一行内容 + for { + line, err2 := reader.ReadString('\n') + if err2 != nil || io.EOF == err2 { + break } - }() + t.Stdout.WriteString(line) + + fmt.Println("success", line) + persistResult(t) + } errReader := bufio.NewReader(stderr) - go func() { - defer wg.Done() - //实时循环读取输出流中的一行内容 - for { - line, err2 := errReader.ReadString('\n') - if err2 != nil || io.EOF == err2 { - break - } - t.Stderr.WriteString(line) - fmt.Println("error", line) - persistResult(t) + //实时循环读取输出流中的一行内容 + for { + line, err2 := errReader.ReadString('\n') + if err2 != nil || io.EOF == err2 { + break } - }() - - wg.Wait() + t.Stderr.WriteString(line) + fmt.Println("error", line) + persistResult(t) + } err := t.Cmd.Wait() if err != nil { From 206a0a8a9637ca65b705f72ce61896762e8f1f99 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Fri, 21 Jun 2024 15:08:54 +0800 Subject: [PATCH 61/70] Update task.go --- ibex/task.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 001676b6..405e7f66 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -315,19 +315,19 @@ func runProcessRealtime(stdout io.ReadCloser, stderr io.ReadCloser, t *Task) { t.SetAlive(true) defer t.SetAlive(false) - reader := bufio.NewReader(stdout) - - //实时循环读取输出流中的一行内容 - for { - line, err2 := reader.ReadString('\n') - if err2 != nil || io.EOF == err2 { - break - } - t.Stdout.WriteString(line) - - fmt.Println("success", line) - persistResult(t) - } + //reader := bufio.NewReader(stdout) + // + ////实时循环读取输出流中的一行内容 + //for { + // line, err2 := reader.ReadString('\n') + // if err2 != nil || io.EOF == err2 { + // break + // } + // t.Stdout.WriteString(line) + // + // fmt.Println("success", line) + // persistResult(t) + //} errReader := bufio.NewReader(stderr) From eb6c3f4bca612dc816b28578d0f2742de0fb7fd0 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Fri, 21 Jun 2024 15:11:17 +0800 Subject: [PATCH 62/70] Update task.go --- ibex/task.go | 56 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 22 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 405e7f66..b50f1e92 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -315,32 +315,44 @@ func runProcessRealtime(stdout io.ReadCloser, stderr io.ReadCloser, t *Task) { t.SetAlive(true) defer t.SetAlive(false) - //reader := bufio.NewReader(stdout) - // - ////实时循环读取输出流中的一行内容 - //for { - // line, err2 := reader.ReadString('\n') - // if err2 != nil || io.EOF == err2 { - // break - // } - // t.Stdout.WriteString(line) - // - // fmt.Println("success", line) - // persistResult(t) - //} + var wg sync.WaitGroup + + wg.Add(2) + + reader := bufio.NewReader(stdout) + + go func() { + defer wg.Done() + //实时循环读取输出流中的一行内容 + for { + line, err2 := reader.ReadString('\n') + if err2 != nil || io.EOF == err2 { + break + } + t.Stdout.WriteString(line) + + fmt.Println("success", line) + persistResult(t) + } + }() errReader := bufio.NewReader(stderr) - //实时循环读取输出流中的一行内容 - for { - line, err2 := errReader.ReadString('\n') - if err2 != nil || io.EOF == err2 { - break + go func() { + defer wg.Done() + //实时循环读取输出流中的一行内容 + for { + line, err2 := errReader.ReadString('\n') + if err2 != nil || io.EOF == err2 { + break + } + t.Stderr.WriteString(line) + fmt.Println("error", line) + persistResult(t) } - t.Stderr.WriteString(line) - fmt.Println("error", line) - persistResult(t) - } + }() + + wg.Wait() err := t.Cmd.Wait() if err != nil { From 8e9cdfb8752e67dfe870e440185400927b67ca9a Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Fri, 21 Jun 2024 15:23:23 +0800 Subject: [PATCH 63/70] error realtime output --- ibex/task.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index b50f1e92..550f41e3 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -331,7 +331,6 @@ func runProcessRealtime(stdout io.ReadCloser, stderr io.ReadCloser, t *Task) { } t.Stdout.WriteString(line) - fmt.Println("success", line) persistResult(t) } }() @@ -347,7 +346,6 @@ func runProcessRealtime(stdout io.ReadCloser, stderr io.ReadCloser, t *Task) { break } t.Stderr.WriteString(line) - fmt.Println("error", line) persistResult(t) } }() From 40335bdb18f313ee57f294aca54bfa5461f361df Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Tue, 2 Jul 2024 10:32:43 +0800 Subject: [PATCH 64/70] a --- ibex/task.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ibex/task.go b/ibex/task.go index 550f41e3..f1506df8 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -353,6 +353,7 @@ func runProcessRealtime(stdout io.ReadCloser, stderr io.ReadCloser, t *Task) { wg.Wait() err := t.Cmd.Wait() + fmt.Println("err ======> ", err) if err != nil { if strings.Contains(err.Error(), "signal: killed") { t.SetStatus("killed") @@ -379,6 +380,7 @@ func persistResult(t *Task) { file.WriteString(stdout, t.GetStdout()) file.WriteString(stderr, t.GetStderr()) + fmt.Println("status =======> ", t.GetStatus()) file.WriteString(doneFlag, t.GetStatus()) } From dab45db22fff7a4f0f4ca3802aae8272d24bde08 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Tue, 2 Jul 2024 11:02:51 +0800 Subject: [PATCH 65/70] Update task.go --- ibex/task.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index f1506df8..19f6983f 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -323,7 +323,6 @@ func runProcessRealtime(stdout io.ReadCloser, stderr io.ReadCloser, t *Task) { go func() { defer wg.Done() - //实时循环读取输出流中的一行内容 for { line, err2 := reader.ReadString('\n') if err2 != nil || io.EOF == err2 { @@ -339,7 +338,6 @@ func runProcessRealtime(stdout io.ReadCloser, stderr io.ReadCloser, t *Task) { go func() { defer wg.Done() - //实时循环读取输出流中的一行内容 for { line, err2 := errReader.ReadString('\n') if err2 != nil || io.EOF == err2 { @@ -370,6 +368,8 @@ func runProcessRealtime(stdout io.ReadCloser, stderr io.ReadCloser, t *Task) { t.SetStatus("success") log.Printf("D! process of task[%d] done", t.Id) } + + persistResult(t) } func persistResult(t *Task) { From 31f81845f43ba67c145f8dc13cb50b5b0911b0e1 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Tue, 2 Jul 2024 11:24:22 +0800 Subject: [PATCH 66/70] Update task.go --- ibex/task.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 19f6983f..201132fb 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -315,14 +315,9 @@ func runProcessRealtime(stdout io.ReadCloser, stderr io.ReadCloser, t *Task) { t.SetAlive(true) defer t.SetAlive(false) - var wg sync.WaitGroup - - wg.Add(2) - reader := bufio.NewReader(stdout) go func() { - defer wg.Done() for { line, err2 := reader.ReadString('\n') if err2 != nil || io.EOF == err2 { @@ -337,7 +332,6 @@ func runProcessRealtime(stdout io.ReadCloser, stderr io.ReadCloser, t *Task) { errReader := bufio.NewReader(stderr) go func() { - defer wg.Done() for { line, err2 := errReader.ReadString('\n') if err2 != nil || io.EOF == err2 { @@ -348,8 +342,6 @@ func runProcessRealtime(stdout io.ReadCloser, stderr io.ReadCloser, t *Task) { } }() - wg.Wait() - err := t.Cmd.Wait() fmt.Println("err ======> ", err) if err != nil { @@ -369,7 +361,7 @@ func runProcessRealtime(stdout io.ReadCloser, stderr io.ReadCloser, t *Task) { log.Printf("D! process of task[%d] done", t.Id) } - persistResult(t) + //persistResult(t) } func persistResult(t *Task) { From 5ca023f715920f60c21804064e1f215c30ba89fb Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Tue, 2 Jul 2024 11:24:43 +0800 Subject: [PATCH 67/70] Update task.go --- ibex/task.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibex/task.go b/ibex/task.go index 201132fb..accd44fe 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -361,7 +361,7 @@ func runProcessRealtime(stdout io.ReadCloser, stderr io.ReadCloser, t *Task) { log.Printf("D! process of task[%d] done", t.Id) } - //persistResult(t) + persistResult(t) } func persistResult(t *Task) { From f65d04f1bcb637a78a05f207963d209fd1d03464 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Tue, 2 Jul 2024 11:56:48 +0800 Subject: [PATCH 68/70] Update task.go --- ibex/task.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ibex/task.go b/ibex/task.go index accd44fe..8730fd5c 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -372,8 +372,10 @@ func persistResult(t *Task) { file.WriteString(stdout, t.GetStdout()) file.WriteString(stderr, t.GetStderr()) - fmt.Println("status =======> ", t.GetStatus()) + fmt.Println("stdout =======> ", t.GetStdout()) + fmt.Println("stderr =======> ", t.GetStderr()) file.WriteString(doneFlag, t.GetStatus()) + fmt.Println("status =======> ", t.GetStatus()) } func killProcess(t *Task) { From 18d72d519d547f88a86429258c2b23f67e4c27c7 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Tue, 2 Jul 2024 15:38:39 +0800 Subject: [PATCH 69/70] Update task.go --- ibex/task.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 8730fd5c..174a503c 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -343,7 +343,7 @@ func runProcessRealtime(stdout io.ReadCloser, stderr io.ReadCloser, t *Task) { }() err := t.Cmd.Wait() - fmt.Println("err ======> ", err) + //fmt.Println("err ======> ", err) if err != nil { if strings.Contains(err.Error(), "signal: killed") { t.SetStatus("killed") @@ -372,10 +372,10 @@ func persistResult(t *Task) { file.WriteString(stdout, t.GetStdout()) file.WriteString(stderr, t.GetStderr()) - fmt.Println("stdout =======> ", t.GetStdout()) - fmt.Println("stderr =======> ", t.GetStderr()) + //fmt.Println("stdout =======> ", t.GetStdout()) + //fmt.Println("\t", t.GetStderr()) file.WriteString(doneFlag, t.GetStatus()) - fmt.Println("status =======> ", t.GetStatus()) + //fmt.Println("\t", t.GetStatus()) } func killProcess(t *Task) { From dd2cee8c5c9e500ba0a1add2fac8d11c39f10d69 Mon Sep 17 00:00:00 2001 From: zhaochengpro <147230368+NeganZhao@users.noreply.github.com> Date: Thu, 11 Jul 2024 16:30:27 +0800 Subject: [PATCH 70/70] Update task.go --- ibex/task.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ibex/task.go b/ibex/task.go index 174a503c..47892bcb 100644 --- a/ibex/task.go +++ b/ibex/task.go @@ -343,7 +343,6 @@ func runProcessRealtime(stdout io.ReadCloser, stderr io.ReadCloser, t *Task) { }() err := t.Cmd.Wait() - //fmt.Println("err ======> ", err) if err != nil { if strings.Contains(err.Error(), "signal: killed") { t.SetStatus("killed") @@ -372,10 +371,7 @@ func persistResult(t *Task) { file.WriteString(stdout, t.GetStdout()) file.WriteString(stderr, t.GetStderr()) - //fmt.Println("stdout =======> ", t.GetStdout()) - //fmt.Println("\t", t.GetStderr()) file.WriteString(doneFlag, t.GetStatus()) - //fmt.Println("\t", t.GetStatus()) } func killProcess(t *Task) {