mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-08-26 09:23:10 +00:00
Reuse the loaded AI config when restarting the service
Back-port v5 fix 716340dcd to v6. Extracts startWithConfig from Start so
Restart passes the config it already loaded down to the start path, instead
of Start re-reading loadAIConfig a second time. Avoids starting the AI
service with a stale/inconsistent config if it changed between Restart's
load and the start. Both Restart start paths now use startWithConfig.
This commit is contained in:
parent
3928b19803
commit
a6b773a85f
1 changed files with 9 additions and 3 deletions
|
|
@ -728,6 +728,12 @@ func (h *AIHandler) clearApprovalStore() {
|
|||
func (h *AIHandler) Start(ctx context.Context, monitor *monitoring.Monitor) error {
|
||||
log.Info().Msg("AIHandler.Start called")
|
||||
aiCfg := h.loadAIConfig(ctx)
|
||||
return h.startWithConfig(ctx, monitor, aiCfg)
|
||||
}
|
||||
|
||||
// startWithConfig starts the AI service with an already-loaded config so callers
|
||||
// such as Restart do not re-read (and risk racing) the config a second time.
|
||||
func (h *AIHandler) startWithConfig(ctx context.Context, monitor *monitoring.Monitor, aiCfg *config.AIConfig) error {
|
||||
if aiCfg == nil {
|
||||
log.Info().Msg("AI config is nil, AI is disabled")
|
||||
return nil
|
||||
|
|
@ -825,7 +831,7 @@ func (h *AIHandler) Restart(ctx context.Context) error {
|
|||
m, _ = mtm.GetMonitor("default")
|
||||
}
|
||||
|
||||
return h.Start(ctx, m)
|
||||
return h.startWithConfig(ctx, m, newCfg)
|
||||
}
|
||||
|
||||
if !svc.IsRunning() {
|
||||
|
|
@ -841,8 +847,8 @@ func (h *AIHandler) Restart(ctx context.Context) error {
|
|||
m, _ = mtm.GetMonitor("default")
|
||||
}
|
||||
|
||||
// Reuse start logic
|
||||
return h.Start(ctx, m)
|
||||
// Reuse start logic with the already-loaded config (avoid a second load)
|
||||
return h.startWithConfig(ctx, m, newCfg)
|
||||
}
|
||||
|
||||
if err := svc.Restart(ctx, newCfg); err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue