优化配置读取规则,只允许读取.json配置

This commit is contained in:
orgin
2022-10-13 14:29:49 +08:00
parent d87ad419c8
commit 17a448f75c

View File

@@ -6,6 +6,7 @@ import (
"github.com/duanhf2012/origin/rpc" "github.com/duanhf2012/origin/rpc"
jsoniter "github.com/json-iterator/go" jsoniter "github.com/json-iterator/go"
"os" "os"
"path/filepath"
"strings" "strings"
) )
@@ -126,6 +127,10 @@ func (cls *Cluster) readLocalService(localNodeId int) error {
continue continue
} }
if filepath.Ext(f.Name())!= ".json" {
continue
}
filePath := strings.TrimRight(strings.TrimRight(clusterCfgPath, "/"), "\\") + "/" + f.Name() filePath := strings.TrimRight(strings.TrimRight(clusterCfgPath, "/"), "\\") + "/" + f.Name()
currGlobalCfg, serviceConfig, mapNodeService, err := cls.readServiceConfig(filePath) currGlobalCfg, serviceConfig, mapNodeService, err := cls.readServiceConfig(filePath)
if err != nil { if err != nil {