cmd/revid-cli & revid: using goto to sleep for monitor period, and using wg.Done() at the end of output routine.

This commit is contained in:
saxon 2019-02-04 17:12:30 +10:30
parent 93e3899725
commit 8978f9edc5
2 changed files with 8 additions and 3 deletions

View File

@ -253,12 +253,15 @@ func handleFlags() revid.Config {
func run(cfg revid.Config) error {
log.Log(logger.Info, pkg+"running in NetSender mode")
var err error
var vars map[string]string
// initialize NetSender and use NetSender's logger
var ns netsender.Sender
if err := ns.Init(log, nil, nil, nil); err != nil {
return err
}
vars, _ := ns.Vars()
vars, _ = ns.Vars()
vs := ns.VarSum()
rv, err := revid.New(cfg, &ns)
@ -291,10 +294,10 @@ func run(cfg revid.Config) error {
// If var sum hasn't change we continue
if vs == ns.VarSum() {
continue
goto sleep
}
vars, err := ns.Vars()
vars, err = ns.Vars()
if err != nil {
log.Log(logger.Error, pkg+"netSender failed to get vars", "error", err.Error())
time.Sleep(netSendRetryTime)
@ -324,6 +327,7 @@ func run(cfg revid.Config) error {
}
ns.SetMode(paused, &vs)
}
sleep:
sleepTime, _ := strconv.Atoi(ns.Param("mp"))
time.Sleep(time.Duration(sleepTime) * time.Second)
}

View File

@ -582,6 +582,7 @@ loop:
r.config.Logger.Log(logger.Error, pkg+"failed to close output"+strconv.Itoa(i)+" destination", "error", err.Error())
}
}
r.wg.Done()
}
// startRaspivid sets up things for input from raspivid i.e. starts