From 63652b9a7795c12ed2d8a2186b29e824cfe888e5 Mon Sep 17 00:00:00 2001 From: BaiMeow Date: Thu, 7 Mar 2024 11:08:22 +0800 Subject: [PATCH] fix: only init conf when running service --- cmd/bounce.go | 1 - cmd/root.go | 2 -- cmd/service.go | 2 ++ 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cmd/bounce.go b/cmd/bounce.go index cecbf88..c1675cc 100644 --- a/cmd/bounce.go +++ b/cmd/bounce.go @@ -35,5 +35,4 @@ var bounceCmd = &cobra.Command{ func init() { rootCmd.AddCommand(bounceCmd) - } diff --git a/cmd/root.go b/cmd/root.go index 268272e..fc6b742 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,7 +1,6 @@ package cmd import ( - "github.com/hdu-dn11/wg-quick-op/conf" "github.com/sirupsen/logrus" "os" @@ -32,7 +31,6 @@ func init() { if verbose { logrus.SetLevel(logrus.DebugLevel) } - conf.Init(config) } rootCmd.PersistentFlags().StringVarP(&config, "config", "c", "/etc/wg-quick-op.yaml", "config file path") } diff --git a/cmd/service.go b/cmd/service.go index 4567cbc..70ec3d8 100644 --- a/cmd/service.go +++ b/cmd/service.go @@ -1,6 +1,7 @@ package cmd import ( + "github.com/hdu-dn11/wg-quick-op/conf" "github.com/hdu-dn11/wg-quick-op/daemon" "github.com/spf13/cobra" @@ -13,6 +14,7 @@ var serviceCmd = &cobra.Command{ Long: `run service in backend. the service will read config file, according to the config file, it do ddns resolve updating, specific interface upping and so on`, Run: func(cmd *cobra.Command, args []string) { + conf.Init(config) daemon.Serve() }, }