mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-03 02:42:19 +08:00
fix: fix the func
This commit is contained in:
parent
03284384d0
commit
0fe248c2b9
@ -15,9 +15,6 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/constant"
|
"github.com/OpenIMSDK/protocol/constant"
|
||||||
"github.com/openimsdk/open-im-server/v3/internal/api"
|
"github.com/openimsdk/open-im-server/v3/internal/api"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -38,7 +35,6 @@ func NewApiCmd() *ApiCmd {
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
// 原来代码
|
|
||||||
func (a *ApiCmd) addPreRun() {
|
func (a *ApiCmd) addPreRun() {
|
||||||
a.Command.PreRun = func(cmd *cobra.Command, args []string) {
|
a.Command.PreRun = func(cmd *cobra.Command, args []string) {
|
||||||
a.port = a.getPortFlag(cmd)
|
a.port = a.getPortFlag(cmd)
|
||||||
@ -52,17 +48,11 @@ func (a *ApiCmd) addRunE() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *ApiCmd) GetPortFromConfig(portType string) (int, error) {
|
func (a *ApiCmd) GetPortFromConfig(portType string) int {
|
||||||
if portType == constant.FlagPort {
|
if portType == constant.FlagPort {
|
||||||
if len(a.config.Api.OpenImApiPort) > 0 {
|
return a.config.Api.OpenImApiPort[0]
|
||||||
return a.config.Api.OpenImApiPort[0], nil
|
|
||||||
}
|
|
||||||
return 0, errors.New("API port configuration is empty or missing")
|
|
||||||
} else if portType == constant.FlagPrometheusPort {
|
} else if portType == constant.FlagPrometheusPort {
|
||||||
if len(a.config.Prometheus.ApiPrometheusPort) > 0 {
|
return a.config.Prometheus.ApiPrometheusPort[0]
|
||||||
return a.config.Prometheus.ApiPrometheusPort[0], nil
|
|
||||||
}
|
|
||||||
return 0, errors.New("Prometheus port configuration is empty or missing")
|
|
||||||
}
|
}
|
||||||
return 0, fmt.Errorf("unknown port type: %s", portType)
|
return 0
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user