mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
fix: ensure log and cache flags are processed during reload
During reload operations, log and cache flags were not being processed, which prevented runtime internal logs from working correctly. To fix this, processLogAndCacheFlags was refactored to accept explicit viper and config parameters instead of relying on global state, enabling it to be called during reload with the new configuration. This ensures that log and cache settings are properly applied when the service reloads its configuration.
This commit is contained in:
committed by
Cuong Manh Le
parent
091c7edb19
commit
80e652b8d9
@@ -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
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user