mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-23 18:00:32 +08:00
Merge branch 'openimsdk:main' into main
This commit is contained in:
commit
df063d29ac
@ -314,7 +314,7 @@ func newGinRouter(ctx context.Context, client discovery.SvcDiscoveryRegistry, cf
|
|||||||
configGroup.POST("/reset_config", cm.ResetConfig)
|
configGroup.POST("/reset_config", cm.ResetConfig)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
r.POST("/restart", cm.Restart)
|
r.POST("/restart", cm.CheckAdmin, cm.Restart)
|
||||||
}
|
}
|
||||||
return r, nil
|
return r, nil
|
||||||
}
|
}
|
||||||
|
@ -143,9 +143,22 @@ func (r *RootCmd) updateConfigFromEtcd(opts *CmdOpts) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
update := func(configFileName string, configStruct any) error {
|
update := func(configFileName string, configStruct any) error {
|
||||||
|
ctx := context.TODO()
|
||||||
key := disetcd.BuildKey(configFileName)
|
key := disetcd.BuildKey(configFileName)
|
||||||
etcdRes, err := r.etcdClient.Get(context.TODO(), key)
|
etcdRes, err := r.etcdClient.Get(ctx, key)
|
||||||
if err != nil || etcdRes.Count == 0 {
|
if err != nil {
|
||||||
|
log.ZWarn(ctx, "root cmd updateConfigFromEtcd, etcd Get err: %v", errs.Wrap(err))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if etcdRes.Count == 0 {
|
||||||
|
data, err := json.Marshal(configStruct)
|
||||||
|
if err != nil {
|
||||||
|
return errs.ErrArgs.WithDetail(err.Error()).Wrap()
|
||||||
|
}
|
||||||
|
_, err = r.etcdClient.Put(ctx, disetcd.BuildKey(configFileName), string(data))
|
||||||
|
if err != nil {
|
||||||
|
log.ZWarn(ctx, "root cmd updateConfigFromEtcd, etcd Put err: %v", errs.Wrap(err))
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
err = json.Unmarshal(etcdRes.Kvs[0].Value, configStruct)
|
err = json.Unmarshal(etcdRes.Kvs[0].Value, configStruct)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user