mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-15 00:40:26 +08:00
全局配置有变化时也提示更新集群
This commit is contained in:
@@ -212,8 +212,14 @@ func (this *ServerDAO) UpdateServerConfig(serverId int64, configJSON []byte, upd
|
|||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
globalConfig, err := SharedSysSettingDAO.ReadSetting(SettingCodeServerGlobalConfig)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
m := md5.New()
|
m := md5.New()
|
||||||
_, _ = m.Write(configJSON)
|
_, _ = m.Write(configJSON) // 当前服务配置
|
||||||
|
_, _ = m.Write(globalConfig) // 全局配置
|
||||||
h := m.Sum(nil)
|
h := m.Sum(nil)
|
||||||
newConfigMd5 := fmt.Sprintf("%x", h)
|
newConfigMd5 := fmt.Sprintf("%x", h)
|
||||||
|
|
||||||
|
|||||||
@@ -801,3 +801,19 @@ func (this *ServerService) CountAllEnabledServersWithGroupId(ctx context.Context
|
|||||||
Count: count,
|
Count: count,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 通知更新
|
||||||
|
func (this *ServerService) NotifyServersChange(ctx context.Context, req *pb.NotifyServersChangeRequest) (*pb.NotifyServersChangeResponse, error) {
|
||||||
|
// 校验请求
|
||||||
|
_, _, err := rpcutils.ValidateRequest(ctx, rpcutils.UserTypeAdmin)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = models.SharedSysEventDAO.CreateEvent(models.NewServerChangeEvent())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &pb.NotifyServersChangeResponse{}, nil
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ func init() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 事件相关处理程序
|
||||||
type EventLooper struct {
|
type EventLooper struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user