From 2386a9db319e99184d329d6a71a21f04f4ef0397 Mon Sep 17 00:00:00 2001 From: soup Date: Sun, 20 Oct 2024 12:56:42 +0200 Subject: [PATCH] fix(config): log reload message once (#1773) fix(config): prevent double logging of config reload message --- internal/config/config.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index f59039a..1bb144f 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -387,8 +387,10 @@ func (c *AppConfig) load(configPath string) { } func (c *AppConfig) DynamicReload(log logger.Logger) { + viper.WatchConfig() viper.OnConfigChange(func(e fsnotify.Event) { c.m.Lock() + defer c.m.Unlock() logLevel := viper.GetString("logLevel") c.Config.LogLevel = logLevel @@ -401,10 +403,7 @@ func (c *AppConfig) DynamicReload(log logger.Logger) { c.Config.CheckForUpdates = checkUpdates log.Debug().Msg("config file reloaded!") - - c.m.Unlock() }) - viper.WatchConfig() } func (c *AppConfig) UpdateConfig() error {