|
|
@ -16,11 +16,12 @@ package startrpc
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
|
|
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/common/discovery_register"
|
|
|
|
|
|
|
|
"net"
|
|
|
|
"net"
|
|
|
|
"strconv"
|
|
|
|
"strconv"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
|
|
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/common/discovery_register"
|
|
|
|
|
|
|
|
|
|
|
|
grpcprometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
|
|
|
|
grpcprometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
"google.golang.org/grpc/credentials/insecure"
|
|
|
|
"google.golang.org/grpc/credentials/insecure"
|
|
|
@ -32,6 +33,7 @@ import (
|
|
|
|
"github.com/OpenIMSDK/tools/utils"
|
|
|
|
"github.com/OpenIMSDK/tools/utils"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Start rpc server.
|
|
|
|
func Start(
|
|
|
|
func Start(
|
|
|
|
rpcPort int,
|
|
|
|
rpcPort int,
|
|
|
|
rpcRegisterName string,
|
|
|
|
rpcRegisterName string,
|
|
|
@ -39,16 +41,8 @@ func Start(
|
|
|
|
rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error,
|
|
|
|
rpcFn func(client discoveryregistry.SvcDiscoveryRegistry, server *grpc.Server) error,
|
|
|
|
options ...grpc.ServerOption,
|
|
|
|
options ...grpc.ServerOption,
|
|
|
|
) error {
|
|
|
|
) error {
|
|
|
|
fmt.Println(
|
|
|
|
fmt.Printf("start %s server, port: %d, prometheusPort: %d, OpenIM version: %s",
|
|
|
|
"start",
|
|
|
|
rpcRegisterName, rpcPort, prometheusPort, config.Version)
|
|
|
|
rpcRegisterName,
|
|
|
|
|
|
|
|
"server, port: ",
|
|
|
|
|
|
|
|
rpcPort,
|
|
|
|
|
|
|
|
"prometheusPort:",
|
|
|
|
|
|
|
|
prometheusPort,
|
|
|
|
|
|
|
|
", OpenIM version: ",
|
|
|
|
|
|
|
|
config.Version,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
listener, err := net.Listen(
|
|
|
|
listener, err := net.Listen(
|
|
|
|
"tcp",
|
|
|
|
"tcp",
|
|
|
|
net.JoinHostPort(network.GetListenIP(config.Config.Rpc.ListenIP), strconv.Itoa(rpcPort)),
|
|
|
|
net.JoinHostPort(network.GetListenIP(config.Config.Rpc.ListenIP), strconv.Itoa(rpcPort)),
|
|
|
@ -63,11 +57,10 @@ func Start(
|
|
|
|
zookeeper.WithFreq(time.Hour), zookeeper.WithUserNameAndPassword(
|
|
|
|
zookeeper.WithFreq(time.Hour), zookeeper.WithUserNameAndPassword(
|
|
|
|
config.Config.Zookeeper.Username,
|
|
|
|
config.Config.Zookeeper.Username,
|
|
|
|
config.Config.Zookeeper.Password,
|
|
|
|
config.Config.Zookeeper.Password,
|
|
|
|
), zookeeper.WithRoundRobin(), zookeeper.WithTimeout(10), zookeeper.WithLogger(log.NewZkLogger()))*/
|
|
|
|
), zookeeper.WithRoundRobin(), zookeeper.WithTimeout(10), zookeeper.WithLogger(log.NewZkLogger()))*/if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
return utils.Wrap1(err)
|
|
|
|
return utils.Wrap1(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//defer zkClient.CloseZK()
|
|
|
|
// defer zkClient.CloseZK()
|
|
|
|
zkClient.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
|
|
|
zkClient.AddOption(mw.GrpcClient(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
|
|
|
registerIP, err := network.GetRpcRegisterIP(config.Config.Rpc.RegisterIP)
|
|
|
|
registerIP, err := network.GetRpcRegisterIP(config.Config.Rpc.RegisterIP)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
@ -108,5 +101,6 @@ func Start(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
return utils.Wrap1(srv.Serve(listener))
|
|
|
|
return utils.Wrap1(srv.Serve(listener))
|
|
|
|
}
|
|
|
|
}
|
|
|
|