Skip to content

Commit

Permalink
feat: make listening only after connection to components prepared
Browse files Browse the repository at this point in the history
  • Loading branch information
CNCSMonster committed Sep 18, 2023
1 parent cc1c5ff commit 76301a5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pkg/common/chatrpcstart/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ import (

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, "server, port: ", rpcPort, "prometheusPort:", prometheusPort, ", OpenIM version: ", config.Version)
listener, err := net.Listen("tcp", net.JoinHostPort(network.GetListenIP(config.Config.Rpc.ListenIP), strconv.Itoa(rpcPort)))
if err != nil {
return err
}
defer listener.Close()

zkClient, err := openKeeper.NewClient(config.Config.Zookeeper.ZkAddr, config.Config.Zookeeper.Schema,
openKeeper.WithFreq(time.Hour), openKeeper.WithUserNameAndPassword(config.Config.Zookeeper.Username,
config.Config.Zookeeper.Password), openKeeper.WithRoundRobin(), openKeeper.WithTimeout(10), openKeeper.WithLogger(log.NewZkLogger()))
Expand All @@ -62,5 +58,10 @@ func Start(rpcPort int, rpcRegisterName string, prometheusPort int, rpcFn func(c
if err != nil {
return utils.Wrap1(err)
}
listener, err := net.Listen("tcp", net.JoinHostPort(network.GetListenIP(config.Config.Rpc.ListenIP), strconv.Itoa(rpcPort)))
if err != nil {
return err
}
defer listener.Close()
return utils.Wrap1(srv.Serve(listener))
}

0 comments on commit 76301a5

Please sign in to comment.