diff --git a/cmd/api/main.go b/cmd/api/main.go index 079747003..277e0d47b 100644 --- a/cmd/api/main.go +++ b/cmd/api/main.go @@ -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") diff --git a/config/config.yaml b/config/config.yaml index 3471196a9..c3c9282c8 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -107,8 +107,7 @@ rpcPort: #rpc服务端口,不建议修改,端 openImAuthPort: [ 10160 ] openImPushPort: [ 10170 ] openImConversationPort: [ 10180 ] - openImRtcPort: [ 10190 ] - openImThirdPort: [ 10200 ] + openImThirdPort: [ 10190 ] rpcRegisterName: #rpc注册服务名,不建议修改 openImUserName: User diff --git a/internal/rpc/auth/auth.go b/internal/rpc/auth/auth.go index d0a6176f4..b70daec18 100644 --- a/internal/rpc/auth/auth.go +++ b/internal/rpc/auth/auth.go @@ -48,7 +48,7 @@ func (s *authServer) UserToken(ctx context.Context, req *pbAuth.UserTokenReq) (* return nil, err } resp.Token = token - resp.ExpireTimeSeconds = config.Config.TokenPolicy.AccessExpire + resp.ExpireTimeSeconds = config.Config.TokenPolicy.AccessExpire * 24 * 60 * 60 return &resp, nil } diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index 3bccace36..053305f26 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -7,10 +7,7 @@ import ( //go:embed version var Version string -var Config struct { - config - Notification notification -} +var Config config type CallBackConfig struct { Enable bool `yaml:"enable"` @@ -264,6 +261,7 @@ type config struct { MessageTransferPrometheusPort []int `yaml:"messageTransferPrometheusPort"` ThirdPrometheusPort []int `yaml:"thirdPrometheusPort"` } `yaml:"prometheus"` + Notification notification `yaml:"notification"` } type notification struct { diff --git a/pkg/common/config/parse.go b/pkg/common/config/parse.go index 651fcc902..8ab68b68f 100644 --- a/pkg/common/config/parse.go +++ b/pkg/common/config/parse.go @@ -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" @@ -86,7 +87,7 @@ func (c *config) GetConfFromRegistry(registry discoveryregistry.SvcDiscoveryRegi } func InitConfig(configFolderPath string) error { - err := Config.initConfig(&Config.config, FileName, configFolderPath) + err := Config.initConfig(&Config, FileName, configFolderPath) if err != nil { return err } @@ -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() +}