cmd/revid-cli: handle failure to start netsender

This commit is contained in:
Dan Kortschak 2018-06-09 10:16:04 +09:30
parent 5bc18e7ed9
commit 165c2ea23e
1 changed files with 11 additions and 5 deletions

View File

@ -31,6 +31,7 @@ import (
"errors"
"flag"
"fmt"
"os"
"os/exec"
"strconv"
"strings"
@ -130,7 +131,7 @@ func main() {
}
// Do we want a netsender session
netSenderFlagPtr := flag.Bool("NetSender", false, "Are we checking vars through netsender?")
useNetsender := flag.Bool("NetSender", false, "Are we checking vars through netsender?")
// User might also want to define how long revid runs for
runDurationPtr := flag.Duration("runDuration", defaultRunDuration, "How long do you want revid to run for?")
@ -249,12 +250,17 @@ func main() {
var ns netsender.Netsender
var vs int
if *netSenderFlagPtr {
if *useNetsender {
// initialize NetSender and use NetSender's logger
config.Logger = netsender.GetLogger()
// FIXME(kortschak): Handle this error appropriately.
ns, _ = netsender.NewNetsender(false, revidReportActions)
var err error
ns, err = netsender.NewNetsender(false, revidReportActions)
if err != nil {
l := smartlogger.New(loggerVerbosity, smartlogger.File, "/var/log/netsender/")
l.Log(progName, "Error", err.Error()) // TODO(kortschak): Make this "Fatal" when that exists.
os.Exit(1)
}
vs = ns.GetVarSum()
} else {
@ -267,7 +273,7 @@ func main() {
paused := false
// loop in NetSender mode
for *netSenderFlagPtr {
for *useNetsender {
if err := sendTo(ns); err != nil {
config.Logger.Log(progName, "Error", err.Error())
time.Sleep(netSendRetryTime)