mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50: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,7 +991,9 @@ 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.
|
||||||
|
ampConfigChanged := oldCfg == nil || !reflect.DeepEqual(oldCfg.AmpCode, cfg.AmpCode)
|
||||||
|
if ampConfigChanged {
|
||||||
if s.ampModule != nil {
|
if s.ampModule != nil {
|
||||||
log.Debugf("triggering amp module config update")
|
log.Debugf("triggering amp module config update")
|
||||||
if err := s.ampModule.OnConfigUpdated(cfg); err != nil {
|
if err := s.ampModule.OnConfigUpdated(cfg); err != nil {
|
||||||
@@ -999,6 +1002,7 @@ func (s *Server) UpdateClients(cfg *config.Config) {
|
|||||||
} else {
|
} else {
|
||||||
log.Warnf("amp module is nil, skipping config update")
|
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.
|
||||||
tokenStore := sdkAuth.GetTokenStore()
|
tokenStore := sdkAuth.GetTokenStore()
|
||||||
|
|||||||
Reference in New Issue
Block a user