fix too much logs when nacos is not avaiable (#2469)

This commit is contained in:
Xin Luo
2025-06-20 14:36:01 +08:00
committed by GitHub
parent dad6278a6d
commit db66df39c4
2 changed files with 8 additions and 3 deletions

View File

@@ -141,12 +141,13 @@ func (n *NacosRegistryClient) listMcpServerConfigs() ([]model.ConfigItem, error)
}) })
if err != nil { if err != nil {
mcpServerLog.Errorf("List mcp server configs for page size %d, page number %d error %v", currentPageNum, DefaultNacosListConfigPageSize) mcpServerLog.Errorf("List mcp server configs for page size %d, page number %d error %v", currentPageNum, DefaultNacosListConfigPageSize, err)
break
} }
if configPage == nil { if configPage == nil {
mcpServerLog.Errorf("List mcp server configs for page size %d, page number %d null %v", currentPageNum, DefaultNacosListConfigPageSize) mcpServerLog.Errorf("List mcp server configs for page size %d, page number %d null", currentPageNum, DefaultNacosListConfigPageSize)
continue break
} }
result = append(result, configPage.PageItems...) result = append(result, configPage.PageItems...)

View File

@@ -50,6 +50,8 @@ const (
DefaultNacosCacheDir = "/var/log/nacos/log/mcp/cache" DefaultNacosCacheDir = "/var/log/nacos/log/mcp/cache"
DefaultNacosNotLoadCache = true DefaultNacosNotLoadCache = true
DefaultNacosLogMaxAge = 3 DefaultNacosLogMaxAge = 3
DefaultNacosLogMaxSize = 64
DefaultNacosLogMaxBackups = 3
DefaultRefreshInterval = time.Second * 30 DefaultRefreshInterval = time.Second * 30
DefaultRefreshIntervalLimit = time.Second * 10 DefaultRefreshIntervalLimit = time.Second * 10
) )
@@ -128,6 +130,8 @@ func NewWatcher(cache memory.Cache, opts ...WatcherOption) (provider.Watcher, er
constant.WithNotLoadCacheAtStart(DefaultNacosNotLoadCache), constant.WithNotLoadCacheAtStart(DefaultNacosNotLoadCache),
constant.WithLogRollingConfig(&constant.ClientLogRollingConfig{ constant.WithLogRollingConfig(&constant.ClientLogRollingConfig{
MaxAge: DefaultNacosLogMaxAge, MaxAge: DefaultNacosLogMaxAge,
MaxSize: DefaultNacosLogMaxSize,
MaxBackups: DefaultNacosLogMaxBackups,
}), }),
constant.WithUpdateCacheWhenEmpty(w.updateCacheWhenEmpty), constant.WithUpdateCacheWhenEmpty(w.updateCacheWhenEmpty),
constant.WithNamespaceId(w.NacosNamespaceId), constant.WithNamespaceId(w.NacosNamespaceId),