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
10
main.go
10
main.go
|
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -55,10 +56,17 @@ func main() {
|
||||||
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
|
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
|
||||||
viper.SetEnvPrefix("NETAUTH")
|
viper.SetEnvPrefix("NETAUTH")
|
||||||
viper.AutomaticEnv()
|
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 {
|
if err := viper.ReadInConfig(); err != nil {
|
||||||
|
var notFound viper.ConfigFileNotFoundError
|
||||||
|
if !errors.As(err, ¬Found) {
|
||||||
appLogger.Error("Error loading config", "error", err)
|
appLogger.Error("Error loading config", "error", err)
|
||||||
os.Exit(5)
|
os.Exit(5)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
nacl, err := netauth.NewWithLog(appLogger.Named("netauth"))
|
nacl, err := netauth.NewWithLog(appLogger.Named("netauth"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -83,7 +91,7 @@ func main() {
|
||||||
appLogger.Warn(" WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ")
|
appLogger.Warn(" WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ")
|
||||||
appLogger.Warn("===================================================================")
|
appLogger.Warn("===================================================================")
|
||||||
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("advisable when bound to localhost, and the bind configuration has")
|
||||||
appLogger.Warn("been detected as not being bound to localhost.")
|
appLogger.Warn("been detected as not being bound to localhost.")
|
||||||
appLogger.Warn("")
|
appLogger.Warn("")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue