mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
script
This commit is contained in:
parent
82f499f942
commit
ae2e09e48b
@ -1,7 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"OpenIM/internal/push"
|
||||
"OpenIM/pkg/common/cmd"
|
||||
"OpenIM/pkg/common/config"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
@ -10,8 +12,11 @@ func main() {
|
||||
pushCmd := cmd.NewPushCmd()
|
||||
pushCmd.AddPortFlag()
|
||||
pushCmd.AddPrometheusPortFlag()
|
||||
pushCmd.AddPush()
|
||||
if err := pushCmd.Execute(); err != nil {
|
||||
if err := pushCmd.Exec(); err != nil {
|
||||
fmt.Println(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
if err := pushCmd.StartSvr(config.Config.RpcRegisterName.OpenImPushName, push.Start); err != nil {
|
||||
fmt.Println(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ import (
|
||||
"net"
|
||||
)
|
||||
|
||||
func start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error, options []grpc.ServerOption) error {
|
||||
func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error, options ...grpc.ServerOption) error {
|
||||
fmt.Println("start", rpcRegisterName, "rpc server, port: ", rpcPort, "prometheusPort:", prometheusPort, ", OpenIM version: ", config.Version)
|
||||
log.NewPrivateLog(constant.LogFileName)
|
||||
listener, err := net.Listen("tcp", fmt.Sprintf("%s:%d", config.Config.ListenIP, rpcPort))
|
||||
@ -60,6 +60,6 @@ func start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(c
|
||||
return rpcFn(zkClient, srv)
|
||||
}
|
||||
|
||||
func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error, options ...grpc.ServerOption) error {
|
||||
return start(rpcPort, rpcRegisterName, prometheusPort, rpcFn, options)
|
||||
}
|
||||
//func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error, options ...grpc.ServerOption) error {
|
||||
// return start(rpcPort, rpcRegisterName, prometheusPort, rpcFn, options)
|
||||
//}
|
||||
|
@ -1,10 +1,9 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"OpenIM/internal/push"
|
||||
"OpenIM/internal/startrpc"
|
||||
"OpenIM/pkg/common/config"
|
||||
"github.com/spf13/cobra"
|
||||
"OpenIM/pkg/discoveryregistry"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type PushCmd struct {
|
||||
@ -12,11 +11,9 @@ type PushCmd struct {
|
||||
}
|
||||
|
||||
func NewPushCmd() *PushCmd {
|
||||
return &PushCmd{NewAuthCmd()}
|
||||
return &PushCmd{NewRpcCmd()}
|
||||
}
|
||||
|
||||
func (r *PushCmd) AddPush() {
|
||||
r.Command.RunE = func(cmd *cobra.Command, args []string) error {
|
||||
return startrpc.Start(r.getPortFlag(cmd), config.Config.RpcRegisterName.OpenImPushName, r.getPrometheusPortFlag(cmd), push.Start)
|
||||
}
|
||||
func (r *PushCmd) StartSvr(name string, rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error) error {
|
||||
return startrpc.Start(r.GetPortFlag(), name, r.GetPrometheusPortFlag(), rpcFn)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user