mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-12 08:29:06 +02:00
[management,signal,proxy,relay,misc] Unify service configuration loading
Service entry points currently resolve defaults, files, environment variables, and flags differently, which makes precedence inconsistent and prevents some services from using config files. Introduce one Viper-backed loader and migrate Combined, Management, Relay, Signal, and Proxy while preserving compatibility aliases and Management template expansion.
This commit is contained in:
+5
-12
@@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
@@ -17,9 +16,8 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
logLevel string
|
||||
defaultLogFile string
|
||||
logFile string
|
||||
logLevel string
|
||||
logFile string
|
||||
|
||||
rootCmd = &cobra.Command{
|
||||
Use: "netbird-signal",
|
||||
@@ -39,14 +37,9 @@ func Execute() error {
|
||||
|
||||
func init() {
|
||||
stopCh = make(chan int)
|
||||
defaultLogFile = "/var/log/netbird/signal.log"
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
defaultLogFile = os.Getenv("PROGRAMDATA") + "\\Netbird\\" + "signal.log"
|
||||
}
|
||||
|
||||
rootCmd.PersistentFlags().StringVar(&logLevel, "log-level", "info", "")
|
||||
rootCmd.PersistentFlags().StringVar(&logFile, "log-file", defaultLogFile, "sets Netbird log path. If console is specified the log will be output to stdout")
|
||||
defaults := defaultConfig()
|
||||
rootCmd.PersistentFlags().StringVar(&logLevel, "log-level", defaults.LogLevel, "")
|
||||
rootCmd.PersistentFlags().StringVar(&logFile, "log-file", defaults.LogFile, "sets Netbird log path. If console is specified the log will be output to stdout")
|
||||
rootCmd.AddCommand(runCmd)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user