mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-09-04 13:36:35 +02: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:
+3
-3
@@ -289,7 +289,7 @@ func run(appCallback *AppCallback, stopCh chan struct{}) {
|
|||||||
}
|
}
|
||||||
p.mu.Unlock()
|
p.mu.Unlock()
|
||||||
|
|
||||||
processLogAndCacheFlags()
|
processLogAndCacheFlags(v, &cfg)
|
||||||
|
|
||||||
// Log config do not have thing to validate, so it's safe to init log here,
|
// 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.
|
// so it's able to log information in processCDFlags.
|
||||||
@@ -340,7 +340,7 @@ func run(appCallback *AppCallback, stopCh chan struct{}) {
|
|||||||
updated := updateListenerConfig(&cfg, notifyExitToLogServer)
|
updated := updateListenerConfig(&cfg, notifyExitToLogServer)
|
||||||
|
|
||||||
if cdUID != "" {
|
if cdUID != "" {
|
||||||
processLogAndCacheFlags()
|
processLogAndCacheFlags(v, &cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Persist intercept_mode to config when provided via CLI flag on full install.
|
// Persist intercept_mode to config when provided via CLI flag on full install.
|
||||||
@@ -851,7 +851,7 @@ func processListenFlag() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// processLogAndCacheFlags processes log and cache related flags
|
// processLogAndCacheFlags processes log and cache related flags
|
||||||
func processLogAndCacheFlags() {
|
func processLogAndCacheFlags(v *viper.Viper, cfg *ctrld.Config) {
|
||||||
mainLog.Load().Debug().Msg("Processing log and cache flags")
|
mainLog.Load().Debug().Msg("Processing log and cache flags")
|
||||||
|
|
||||||
if logPath != "" {
|
if logPath != "" {
|
||||||
|
|||||||
+6
-1
@@ -322,7 +322,8 @@ func (p *prog) runWait() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if cdUID != "" {
|
if cdUID != "" {
|
||||||
if rc, err := processCDFlags(newCfg); err != nil {
|
rc, err := processCDFlags(newCfg)
|
||||||
|
if err != nil {
|
||||||
p.Error().Err(err).Msg("Could not fetch controld config")
|
p.Error().Err(err).Msg("Could not fetch controld config")
|
||||||
waitOldRunDone()
|
waitOldRunDone()
|
||||||
continue
|
continue
|
||||||
@@ -334,6 +335,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()
|
waitOldRunDone()
|
||||||
|
|
||||||
p.mu.Lock()
|
p.mu.Lock()
|
||||||
|
|||||||
Reference in New Issue
Block a user