TUN-1265: Silent exit when failing to parse config

This commit is contained in:
Areg Harutyunyan 2019-01-07 14:30:22 -06:00
parent 8a099d8f6e
commit 8de19dc647
1 changed files with 8 additions and 5 deletions

View File

@ -25,7 +25,7 @@ import (
"github.com/coreos/go-systemd/daemon" "github.com/coreos/go-systemd/daemon"
"github.com/facebookgo/grace/gracenet" "github.com/facebookgo/grace/gracenet"
"github.com/pkg/errors" "github.com/pkg/errors"
cli "gopkg.in/urfave/cli.v2" "gopkg.in/urfave/cli.v2"
"gopkg.in/urfave/cli.v2/altsrc" "gopkg.in/urfave/cli.v2/altsrc"
) )
@ -176,7 +176,7 @@ func Init(v string, s, g chan struct{}) {
} }
func StartServer(c *cli.Context, version string, shutdownC, graceShutdownC chan struct{}) error { func StartServer(c *cli.Context, version string, shutdownC, graceShutdownC chan struct{}) error {
raven.SetDSN(sentryDSN) _ = raven.SetDSN(sentryDSN)
var wg sync.WaitGroup var wg sync.WaitGroup
listeners := gracenet.Net{} listeners := gracenet.Net{}
errC := make(chan error) errC := make(chan error)
@ -209,7 +209,10 @@ func StartServer(c *cli.Context, version string, shutdownC, graceShutdownC chan
if err := os.Rename(tmpTraceFile.Name(), c.String("trace-output")); err != nil { if err := os.Rename(tmpTraceFile.Name(), c.String("trace-output")); err != nil {
logger.WithError(err).Errorf("Failed to rename temporary trace output file %s to %s", tmpTraceFile.Name(), c.String("trace-output")) logger.WithError(err).Errorf("Failed to rename temporary trace output file %s to %s", tmpTraceFile.Name(), c.String("trace-output"))
} else { } else {
os.Remove(tmpTraceFile.Name()) err := os.Remove(tmpTraceFile.Name())
if err != nil {
logger.WithError(err).Errorf("Failed to remove the temporary trace file %s", tmpTraceFile.Name())
}
} }
}() }()
@ -335,12 +338,12 @@ func Before(c *cli.Context) error {
} }
inputSource, err := config.FindInputSourceContext(c) inputSource, err := config.FindInputSourceContext(c)
if err != nil { if err != nil {
logger.WithError(err).Debugf("Cannot load configuration from %s", c.String("config")) logger.WithError(err).Errorf("Cannot load configuration from %s", c.String("config"))
return err return err
} else if inputSource != nil { } else if inputSource != nil {
err := altsrc.ApplyInputSourceValues(c, inputSource, c.App.Flags) err := altsrc.ApplyInputSourceValues(c, inputSource, c.App.Flags)
if err != nil { if err != nil {
logger.WithError(err).Debugf("Cannot apply configuration from %s", c.String("config")) logger.WithError(err).Errorf("Cannot apply configuration from %s", c.String("config"))
return err return err
} }
logger.Debugf("Applied configuration from %s", c.String("config")) logger.Debugf("Applied configuration from %s", c.String("config"))