mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-02 20:40:52 +08:00
fix(api): update amp module only on config changes
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
@@ -990,14 +991,17 @@ func (s *Server) UpdateClients(cfg *config.Config) {
|
|||||||
s.mgmt.SetAuthManager(s.handlers.AuthManager)
|
s.mgmt.SetAuthManager(s.handlers.AuthManager)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify Amp module of config changes (for model mapping hot-reload)
|
// Notify Amp module only when Amp config has changed.
|
||||||
if s.ampModule != nil {
|
ampConfigChanged := oldCfg == nil || !reflect.DeepEqual(oldCfg.AmpCode, cfg.AmpCode)
|
||||||
log.Debugf("triggering amp module config update")
|
if ampConfigChanged {
|
||||||
if err := s.ampModule.OnConfigUpdated(cfg); err != nil {
|
if s.ampModule != nil {
|
||||||
log.Errorf("failed to update Amp module config: %v", err)
|
log.Debugf("triggering amp module config update")
|
||||||
|
if err := s.ampModule.OnConfigUpdated(cfg); err != nil {
|
||||||
|
log.Errorf("failed to update Amp module config: %v", err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.Warnf("amp module is nil, skipping config update")
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
log.Warnf("amp module is nil, skipping config update")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count client sources from configuration and auth store.
|
// Count client sources from configuration and auth store.
|
||||||
|
|||||||
Reference in New Issue
Block a user