diff --git a/main.go b/main.go index 74faa88..6c1f8e5 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "errors" "os" "os/signal" "strings" @@ -55,9 +56,16 @@ func main() { viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) viper.SetEnvPrefix("NETAUTH") viper.AutomaticEnv() + // Every setting has either a default or an environment + // counterpart, so a missing config file is not a reason to + // refuse to start. Anything else (bad syntax, unreadable file) + // still is. if err := viper.ReadInConfig(); err != nil { - appLogger.Error("Error loading config", "error", err) - os.Exit(5) + var notFound viper.ConfigFileNotFoundError + if !errors.As(err, ¬Found) { + appLogger.Error("Error loading config", "error", err) + os.Exit(5) + } } nacl, err := netauth.NewWithLog(appLogger.Named("netauth")) @@ -83,7 +91,7 @@ func main() { appLogger.Warn(" WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ") appLogger.Warn("===================================================================") appLogger.Warn("") - appLogger.Warn("You are launching this server in plaintext mode! This is allowable") + appLogger.Warn("You are launching this server in plaintext mode! This is only") appLogger.Warn("advisable when bound to localhost, and the bind configuration has") appLogger.Warn("been detected as not being bound to localhost.") appLogger.Warn("")