try a really fast loop to see how it works out
This commit is contained in:
parent
a2532b2f3b
commit
7afc01d14e
18
cmd.go
18
cmd.go
|
@ -149,21 +149,31 @@ func PathRunRealtime(pwd string, args []string) cmd.Status {
|
|||
}
|
||||
statusChan := findCmd.Start() // non-blocking
|
||||
|
||||
ticker := time.NewTicker(500 * time.Millisecond)
|
||||
ticker := time.NewTicker(5 * time.Millisecond)
|
||||
|
||||
// this is interesting, maybe useful, but wierd, but neat. interesting even
|
||||
// Print last line of stdout every 2s
|
||||
go func() {
|
||||
// loop very quickly, but only print the line if it changes
|
||||
var lastout string
|
||||
var lasterr string
|
||||
for range ticker.C {
|
||||
status := findCmd.Status()
|
||||
n := len(status.Stdout)
|
||||
if n != 0 {
|
||||
log.Info(status.Stdout[n-1])
|
||||
// fmt.Printf("status", status.Exit, "complete =", status.Complete)
|
||||
newline := status.Stdout[n-1]
|
||||
if lastout != newline {
|
||||
lastout = newline
|
||||
log.Info(lastout)
|
||||
}
|
||||
}
|
||||
n = len(status.Stderr)
|
||||
if n != 0 {
|
||||
log.Info(status.Stderr[n-1])
|
||||
newline := status.Stderr[n-1]
|
||||
if lasterr != newline {
|
||||
lasterr = newline
|
||||
log.Info(lasterr)
|
||||
}
|
||||
}
|
||||
if status.Complete {
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue