diff --git a/cmd/cli/cli.go b/cmd/cli/cli.go index 1984f70..7d70b78 100644 --- a/cmd/cli/cli.go +++ b/cmd/cli/cli.go @@ -282,7 +282,7 @@ func run(appCallback *AppCallback, stopCh chan struct{}) { } p.mu.Unlock() - processLogAndCacheFlags() + processLogAndCacheFlags(v, &cfg) // Log config do not have thing to validate, so it's safe to init log here, // so it's able to log information in processCDFlags. @@ -342,7 +342,7 @@ func run(appCallback *AppCallback, stopCh chan struct{}) { updated := updateListenerConfig(&cfg, notifyExitToLogServer) if cdUID != "" { - processLogAndCacheFlags() + processLogAndCacheFlags(v, &cfg) } if updated { @@ -780,7 +780,8 @@ func processListenFlag() { }) } -func processLogAndCacheFlags() { +// processLogAndCacheFlags processes log and cache related flags +func processLogAndCacheFlags(v *viper.Viper, cfg *ctrld.Config) { if logPath != "" { cfg.Service.LogPath = logPath } diff --git a/cmd/cli/prog.go b/cmd/cli/prog.go index 76f7c36..cf8c680 100644 --- a/cmd/cli/prog.go +++ b/cmd/cli/prog.go @@ -213,7 +213,8 @@ func (p *prog) runWait() { continue } if cdUID != "" { - if rc, err := processCDFlags(newCfg); err != nil { + rc, err := processCDFlags(newCfg) + if err != nil { logger.Err(err).Msg("could not fetch ControlD config") waitOldRunDone() continue @@ -225,6 +226,10 @@ func (p *prog) runWait() { } } + // Though the log configuration could not be changed during reloading, we still need to + // process the current flags here, so runtime internal logs can be used correctly. + processLogAndCacheFlags(v, newCfg) + waitOldRunDone() p.mu.Lock()