diff --git a/cmd/openim-rpc/openim-rpc-auth/__debug_bin b/cmd/openim-rpc/openim-rpc-auth/__debug_bin index d61172178..8c2b69680 100755 Binary files a/cmd/openim-rpc/openim-rpc-auth/__debug_bin and b/cmd/openim-rpc/openim-rpc-auth/__debug_bin differ diff --git a/cmd/openim-rpc/openim-rpc-auth/main.go b/cmd/openim-rpc/openim-rpc-auth/main.go index d27a3f11b..5f858db65 100644 --- a/cmd/openim-rpc/openim-rpc-auth/main.go +++ b/cmd/openim-rpc/openim-rpc-auth/main.go @@ -22,6 +22,9 @@ import ( func main() { authCmd := cmd.NewRpcCmd("auth") + authCmd.PreLoadConfig() + authCmd.SetSvcName(config.Config.RpcRegisterName.OpenImAuthName) + authCmd.AddPortFlag() authCmd.AddPrometheusPortFlag() if err := authCmd.Exec(); err != nil { diff --git a/cmd/openim-rpc/openim-rpc-user/__debug_bin b/cmd/openim-rpc/openim-rpc-user/__debug_bin index 73e796c25..3a928209b 100755 Binary files a/cmd/openim-rpc/openim-rpc-user/__debug_bin and b/cmd/openim-rpc/openim-rpc-user/__debug_bin differ diff --git a/cmd/openim-rpc/openim-rpc-user/main.go b/cmd/openim-rpc/openim-rpc-user/main.go index f2ebc94db..63c2f2d28 100644 --- a/cmd/openim-rpc/openim-rpc-user/main.go +++ b/cmd/openim-rpc/openim-rpc-user/main.go @@ -21,12 +21,16 @@ import ( ) func main() { - rpcCmd := cmd.NewRpcCmd("user") + rpcCmd := cmd.NewRpcCmd("") + rpcCmd.PreLoadConfig() + rpcCmd.SetSvcName(config.Config.RpcRegisterName.OpenImUserName) + rpcCmd.AddPortFlag() rpcCmd.AddPrometheusPortFlag() if err := rpcCmd.Exec(); err != nil { panic(err.Error()) } + if err := rpcCmd.StartSvr(config.Config.RpcRegisterName.OpenImUserName, user.Start); err != nil { panic(err.Error()) } diff --git a/config/config.yaml b/config/config.yaml index e4626040d..d6c8ab292 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -185,7 +185,7 @@ rpcPort: openImGroupPort: [ 10150 ] openImAuthPort: [ 10160 ] openImPushPort: [ 10170 ] - openImConversationPort: [ 10180 ] + openImConversationPort: [ 10230 ] openImThirdPort: [ 10190 ] ###################### RPC Register Name Configuration ###################### @@ -405,5 +405,5 @@ prometheus: pushPrometheusPort: [ 20170 ] conversationPrometheusPort: [ 20230 ] rtcPrometheusPort: [ 21300 ] - thirdPrometheusPort: [ 21301 ] + thirdPrometheusPort: [ 20190 ] messageTransferPrometheusPort: [ 21400, 21401, 21402, 21403 ] # List of ports diff --git a/pkg/common/cmd/root.go b/pkg/common/cmd/root.go index 600498f75..048d4adf2 100644 --- a/pkg/common/cmd/root.go +++ b/pkg/common/cmd/root.go @@ -78,6 +78,16 @@ func NewRootCmd(name string, opts ...func(*CmdOpts)) (rootCmd *RootCmd) { return rootCmd } +func (r *RootCmd) PreLoadConfig() { + if err := config2.InitConfig(""); err != nil { + panic(err) + } +} + +func (r *RootCmd) SetSvcName(name string) { + r.Name = name +} + func (r *RootCmd) addConfFlag() { r.Command.Flags().StringP(constant.FlagConf, "c", "", "Path to config file folder") } @@ -105,6 +115,34 @@ func (r *RootCmd) getPrometheusPortFlag(cmd *cobra.Command) int { } func (r *RootCmd) GetPrometheusPortFlag() int { + if r.prometheusPort == 0 { + switch r.Name { + case config.Config.RpcRegisterName.OpenImAuthName: + return config.Config.Prometheus.AuthPrometheusPort[0] + case config.Config.RpcRegisterName.OpenImUserName: + return config.Config.Prometheus.UserPrometheusPort[0] + case config.Config.RpcRegisterName.OpenImFriendName: + return config.Config.Prometheus.FriendPrometheusPort[0] + case config.Config.RpcRegisterName.OpenImGroupName: + return config.Config.Prometheus.GroupPrometheusPort[0] + case config.Config.RpcRegisterName.OpenImMsgName: + return config.Config.Prometheus.MessagePrometheusPort[0] + case config.Config.RpcRegisterName.OpenImConversationName: + return config.Config.Prometheus.ConversationPrometheusPort[0] + case config.Config.RpcRegisterName.OpenImConversationName: + return config.Config.Prometheus.ConversationPrometheusPort[0] + case config.Config.RpcRegisterName.OpenImPushName: + return config.Config.Prometheus.PushPrometheusPort[0] + case config.Config.RpcRegisterName.OpenImMessageGatewayName: + return config.Config.Prometheus.MessageGatewayPrometheusPort[0] + case config.Config.RpcRegisterName.OpenImThirdName: + return config.Config.Prometheus.ThirdPrometheusPort[0] + default: + return 0 + + } + } + return r.prometheusPort }