Skip to content

Commit

Permalink
sync: wait for the log to be printed before the work process exits (#…
Browse files Browse the repository at this point in the history
…5362)

(cherry picked from commit 66bb3e7)
  • Loading branch information
zhijian-pro committed Dec 13, 2024
1 parent 406c486 commit f96bb3a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/sync/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,17 +306,20 @@ func launchWorker(address string, config *Config, wg *sync.WaitGroup) {
return
}
logger.Infof("launch a worker on %s", host)
var finished = make(chan struct{})
go func() {
r := bufio.NewReader(stderr)
for {
line, err := r.ReadString('\n')
if err != nil || len(line) == 0 {
finished <- struct{}{}
return
}
println(host, line[:len(line)-1])
}
}()
err = cmd.Wait()
<-finished
if err != nil {
logger.Errorf("%s: %s", host, err)
}
Expand Down

0 comments on commit f96bb3a

Please sign in to comment.