mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-15 03:11:02 +01:00
Print out errors on exit from cmd
This commit is contained in:
parent
c057fbd4f4
commit
86f1724efa
@ -64,6 +64,8 @@ var (
|
||||
Short: "Relay service",
|
||||
Long: "Relay service for Netbird agents",
|
||||
RunE: execute,
|
||||
SilenceUsage: true,
|
||||
SilenceErrors: true,
|
||||
}
|
||||
)
|
||||
|
||||
@ -128,7 +130,7 @@ func execute(cmd *cobra.Command, args []string) error {
|
||||
err = cfg.Validate()
|
||||
if err != nil {
|
||||
log.Errorf("invalid config: %s", err)
|
||||
os.Exit(1)
|
||||
return err
|
||||
}
|
||||
|
||||
metricsServer, err := metrics.NewServer(metricsPort, "")
|
||||
@ -170,7 +172,7 @@ func execute(cmd *cobra.Command, args []string) error {
|
||||
log.Infof("server will be available on: %s", srv.InstanceURL())
|
||||
go func() {
|
||||
if err := srv.Listen(srvListenerCfg); err != nil {
|
||||
log.Errorf("failed to bind server: %s", err)
|
||||
log.Fatalf("failed to bind server: %s", err)
|
||||
}
|
||||
}()
|
||||
|
||||
@ -185,6 +187,7 @@ func execute(cmd *cobra.Command, args []string) error {
|
||||
shutDownErrors = multierror.Append(shutDownErrors, fmt.Errorf("failed to close server: %s", err))
|
||||
}
|
||||
|
||||
log.Infof("shutting down metrics server")
|
||||
if err := metricsServer.Close(); err != nil {
|
||||
shutDownErrors = multierror.Append(shutDownErrors, fmt.Errorf("failed to close metrics server: %v", err))
|
||||
}
|
||||
@ -200,8 +203,7 @@ func setupTLSCertManager(letsencryptDataDir string, letsencryptDomains ...string
|
||||
}
|
||||
|
||||
func main() {
|
||||
err := rootCmd.Execute()
|
||||
if err != nil {
|
||||
os.Exit(1)
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
log.Fatalf("%v", err)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user