mirror of
https://github.com/netauth/ldap.git
synced 2026-11-03 11:43:44 -06:00
main: Allow starting without a config file
This commit is contained in:
parent
9a270abbf2
commit
8263737b18
14
main.go
14
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("")
|
||||
|
|
|
|||
Loading…
Reference in a new issue