mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-03 23:20:26 +08:00
创建集群的时候初始化全局服务配置
This commit is contained in:
@@ -125,7 +125,7 @@ func (this *NodeClusterDAO) FindAllEnableClusterIds(tx *dbs.Tx) (result []int64,
|
||||
}
|
||||
|
||||
// CreateCluster 创建集群
|
||||
func (this *NodeClusterDAO) CreateCluster(tx *dbs.Tx, adminId int64, name string, grantId int64, installDir string, dnsDomainId int64, dnsName string, dnsTTL int32, cachePolicyId int64, httpFirewallPolicyId int64, systemServices map[string]maps.Map) (clusterId int64, err error) {
|
||||
func (this *NodeClusterDAO) CreateCluster(tx *dbs.Tx, adminId int64, name string, grantId int64, installDir string, dnsDomainId int64, dnsName string, dnsTTL int32, cachePolicyId int64, httpFirewallPolicyId int64, systemServices map[string]maps.Map, globalServerConfig *serverconfigs.GlobalServerConfig) (clusterId int64, err error) {
|
||||
uniqueId, err := this.GenUniqueId(tx)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -173,6 +173,16 @@ func (this *NodeClusterDAO) CreateCluster(tx *dbs.Tx, adminId int64, name string
|
||||
}
|
||||
op.SystemServices = systemServicesJSON
|
||||
|
||||
// 全局服务配置
|
||||
if globalServerConfig == nil {
|
||||
globalServerConfig = serverconfigs.DefaultGlobalServerConfig()
|
||||
}
|
||||
globalServerConfigJSON, err := json.Marshal(globalServerConfig)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
op.GlobalServerConfig = globalServerConfigJSON
|
||||
|
||||
op.UseAllAPINodes = 1
|
||||
op.ApiNodes = "[]"
|
||||
op.UniqueId = uniqueId
|
||||
|
||||
@@ -32,6 +32,19 @@ func (this *NodeClusterService) CreateNodeCluster(ctx context.Context, req *pb.C
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 全局服务配置
|
||||
var serverGlobalConfig = serverconfigs.DefaultGlobalServerConfig()
|
||||
if len(req.GlobalServerConfigJSON) > 0 {
|
||||
err = json.Unmarshal(req.GlobalServerConfigJSON, serverGlobalConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = serverGlobalConfig.Init()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// 系统服务
|
||||
var systemServices = map[string]maps.Map{}
|
||||
if len(req.SystemServicesJSON) > 0 {
|
||||
@@ -66,7 +79,7 @@ func (this *NodeClusterService) CreateNodeCluster(ctx context.Context, req *pb.C
|
||||
req.DnsTTL = 0
|
||||
}
|
||||
|
||||
clusterId, err = models.SharedNodeClusterDAO.CreateCluster(tx, adminId, req.Name, req.NodeGrantId, req.InstallDir, req.DnsDomainId, req.DnsName, req.DnsTTL, req.HttpCachePolicyId, req.HttpFirewallPolicyId, systemServices)
|
||||
clusterId, err = models.SharedNodeClusterDAO.CreateCluster(tx, adminId, req.Name, req.NodeGrantId, req.InstallDir, req.DnsDomainId, req.DnsName, req.DnsTTL, req.HttpCachePolicyId, req.HttpFirewallPolicyId, systemServices, serverGlobalConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user