Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
yeya24 committed Mar 9, 2020
1 parent 0259a97 commit 3851386
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func waitRestoreFinish(lightningIPs []string, deployDir, pattern string) (err er
}()
go func() {
defer wg.Done()
if _, err = runCmdAndGetStdOutInTimeAndMatchPattern(stdOutMsg, pattern, "ssh", ip, fmt.Sprintf(`tail -f %s/log/tidb_lightning.log | sed '/^%s$/ q'`, deployDir, pattern)); err != nil {
if _, err = runCmdAndGetStdOutInTimeAndMatchPattern(stdOutMsg, pattern, "ssh", ip, fmt.Sprintf(`tail -f %s/log/tidb_lightning.log`, deployDir)); err != nil {
if err != nil {
errCh <- err
return
Expand Down Expand Up @@ -467,6 +467,7 @@ func runCmdAndGetStdOutInTimeAndMatchPattern(stdOutMsg chan string, pattern, nam
fmt.Println(err)
return
}
var match bool
reader := bufio.NewReader(stdout)
var line string
for {
Expand All @@ -480,13 +481,19 @@ func runCmdAndGetStdOutInTimeAndMatchPattern(stdOutMsg chan string, pattern, nam
}
stdOutMsg <- line
if strings.Contains(line, pattern) {
match = true
break
}
}
stdErrBytes, err = ioutil.ReadAll(stderr)
if err != nil {
return
}
if match {
go func() {
cmd.Process.Kill()
}()
}
if err = cmd.Wait(); err != nil {
fmt.Printf("%s", stdErrBytes)
}
Expand Down

0 comments on commit 3851386

Please sign in to comment.