Files
open-im-server/pkg/common/cmd/msg_gateway.go
T

37 lines
906 B
Go
Raw Normal View History

2023-03-08 11:45:54 +08:00
package cmd
2023-03-08 13:34:12 +08:00
import (
2023-03-16 10:46:06 +08:00
"github.com/OpenIMSDK/Open-IM-Server/internal/msggateway"
//"github.com/OpenIMSDK/Open-IM-Server/internal/msggateway"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
2023-03-08 13:34:12 +08:00
"github.com/spf13/cobra"
)
type MsgGatewayCmd struct {
*RootCmd
}
func NewMsgGatewayCmd() MsgGatewayCmd {
2023-03-13 12:34:56 +08:00
return MsgGatewayCmd{NewRootCmd("msgGateway")}
2023-03-08 13:34:12 +08:00
}
func (m *MsgGatewayCmd) AddWsPortFlag() {
m.Command.Flags().IntP(constant.FlagWsPort, "w", 0, "ws server listen port")
}
func (m *MsgGatewayCmd) getWsPortFlag(cmd *cobra.Command) int {
port, _ := cmd.Flags().GetInt(constant.FlagWsPort)
return port
}
2023-03-08 19:25:27 +08:00
func (m *MsgGatewayCmd) addRunE() {
m.Command.RunE = func(cmd *cobra.Command, args []string) error {
return msggateway.RunWsAndServer(m.getPortFlag(cmd), m.getWsPortFlag(cmd), m.getPrometheusPortFlag(cmd))
2023-03-08 13:34:12 +08:00
}
}
func (m *MsgGatewayCmd) Exec() error {
2023-03-08 19:25:27 +08:00
m.addRunE()
2023-03-08 13:34:12 +08:00
return m.Execute()
}