Update parameter of API startGrpc (#13282)

Signed-off-by: yudong.cai <yudong.cai@zilliz.com>
This commit is contained in:
Cai Yudong 2021-12-13 21:39:10 +08:00 committed by GitHub
parent a76ea1bfc4
commit 973b98c721
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -158,7 +158,7 @@ func (s *Server) init() error {
return err
}
err = s.startGrpc()
err = s.startGrpc(Params.Port)
if err != nil {
return err
}
@ -209,15 +209,15 @@ func (s *Server) init() error {
return s.rootCoord.Init()
}
func (s *Server) startGrpc() error {
func (s *Server) startGrpc(port int) error {
s.wg.Add(1)
go s.startGrpcLoop(Params.Port)
go s.startGrpcLoop(port)
// wait for grpc server loop start
err := <-s.grpcErrChan
return err
}
func (s *Server) startGrpcLoop(grpcPort int) {
func (s *Server) startGrpcLoop(port int) {
defer s.wg.Done()
var kaep = keepalive.EnforcementPolicy{
MinTime: 5 * time.Second, // If a client pings more than once every 5 seconds, terminate the connection
@ -228,8 +228,8 @@ func (s *Server) startGrpcLoop(grpcPort int) {
Time: 60 * time.Second, // Ping the client if it is idle for 60 seconds to ensure the connection is still active
Timeout: 10 * time.Second, // Wait 10 second for the ping ack before assuming the connection is dead
}
log.Debug("start grpc ", zap.Int("port", grpcPort))
lis, err := net.Listen("tcp", ":"+strconv.Itoa(grpcPort))
log.Debug("start grpc ", zap.Int("port", port))
lis, err := net.Listen("tcp", ":"+strconv.Itoa(port))
if err != nil {
log.Error("GrpcServer:failed to listen", zap.String("error", err.Error()))
s.grpcErrChan <- err

View File

@ -103,7 +103,7 @@ func TestGrpcService(t *testing.T) {
err = core.Register()
assert.Nil(t, err)
err = svr.startGrpc()
err = svr.startGrpc(Params.Port)
assert.Nil(t, err)
svr.rootCoord.UpdateStateCode(internalpb.StateCode_Initializing)