pull/454/head^2
withchao 2 years ago
parent d823d11cdd
commit 1e65eb68c2

@ -1,7 +1,6 @@
package main
import (
"bytes"
"context"
"fmt"
"net"
@ -10,8 +9,6 @@ import (
"strconv"
"time"
"gopkg.in/yaml.v3"
"net/http"
_ "net/http/pprof"
@ -61,12 +58,8 @@ func run(port int) error {
return err
}
fmt.Println("api init discov client success")
buf := bytes.NewBuffer(nil)
if err := yaml.NewEncoder(buf).Encode(config.Config); err != nil {
return err
}
fmt.Println("api register public config to discov")
if err := client.RegisterConf2Registry(constant.OpenIMCommonConfigKey, buf.Bytes()); err != nil {
if err := client.RegisterConf2Registry(constant.OpenIMCommonConfigKey, config.EncodeConfig()); err != nil {
return err
}
fmt.Println("api register public config to discov success")

@ -1,6 +1,7 @@
package config
import (
"bytes"
"fmt"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
@ -96,3 +97,11 @@ func InitConfig(configFolderPath string) error {
}
return nil
}
func EncodeConfig() []byte {
buf := bytes.NewBuffer(nil)
if err := yaml.NewEncoder(buf).Encode(Config); err != nil {
panic(err)
}
return buf.Bytes()
}

Loading…
Cancel
Save