Add error handling for when connection to socket fails

This commit is contained in:
Maarten Everts 2020-09-04 16:11:32 +02:00
parent 599c65adb2
commit e9ba7bccbd

View file

@ -17,6 +17,7 @@ package cmd
import ( import (
"fmt" "fmt"
"log"
"os" "os"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -50,7 +51,11 @@ func init() {
RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.signald-cli.yaml)") RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.signald-cli.yaml)")
RootCmd.PersistentFlags().StringVarP(&socketPath, "socket", "s", "/var/run/signald/signald.sock", "the path to the signald socket file") RootCmd.PersistentFlags().StringVarP(&socketPath, "socket", "s", "/var/run/signald/signald.sock", "the path to the signald socket file")
s = &signald.Signald{SocketPath: socketPath} s = &signald.Signald{SocketPath: socketPath}
s.Connect() err := s.Connect()
if err != nil {
log.Fatal(err)
}
} }
// initConfig reads in config file and ENV variables if set. // initConfig reads in config file and ENV variables if set.