Merged in netsend-fail (pull request #27)

cmd/revid-cli: handle failure to start netsender
This commit is contained in:
kortschak 2018-06-09 01:10:31 +00:00 committed by Alan Noble
commit 709de3f119
1 changed files with 11 additions and 5 deletions

View File

@ -31,6 +31,7 @@ import (
"errors" "errors"
"flag" "flag"
"fmt" "fmt"
"os"
"os/exec" "os/exec"
"strconv" "strconv"
"strings" "strings"
@ -130,7 +131,7 @@ func main() {
} }
// Do we want a netsender session // 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 // 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?") 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 ns netsender.Netsender
var vs int var vs int
if *netSenderFlagPtr { if *useNetsender {
// initialize NetSender and use NetSender's logger // initialize NetSender and use NetSender's logger
config.Logger = netsender.GetLogger() config.Logger = netsender.GetLogger()
// FIXME(kortschak): Handle this error appropriately. var err error
ns, _ = netsender.NewNetsender(false, revidReportActions) 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() vs = ns.GetVarSum()
} else { } else {
@ -267,7 +273,7 @@ func main() {
paused := false paused := false
// loop in NetSender mode // loop in NetSender mode
for *netSenderFlagPtr { for *useNetsender {
if err := sendTo(ns); err != nil { if err := sendTo(ns); err != nil {
config.Logger.Log(progName, "Error", err.Error()) config.Logger.Log(progName, "Error", err.Error())
time.Sleep(netSendRetryTime) time.Sleep(netSendRetryTime)