Skip to content

Commit

Permalink
chore: update restful/grpc servers shutdown stages (zeromicro#3662)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan committed Oct 23, 2023
1 parent 00db97f commit c2ff008
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rest/internal/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func start(host string, port int, handler http.Handler, run func(svr *http.Serve
}
healthManager := health.NewHealthManager(fmt.Sprintf("%s-%s:%d", probeNamePrefix, host, port))

waitForCalled := proc.AddWrapUpListener(func() {
waitForCalled := proc.AddShutdownListener(func() {
healthManager.MarkNotReady()
if e := server.Shutdown(context.Background()); e != nil {
logx.Error(e)
Expand Down
2 changes: 1 addition & 1 deletion zrpc/internal/rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (s *rpcServer) Start(register RegisterFn) error {

// we need to make sure all others are wrapped up,
// so we do graceful stop at shutdown phase instead of wrap up phase
waitForCalled := proc.AddWrapUpListener(func() {
waitForCalled := proc.AddShutdownListener(func() {
if s.health != nil {
s.health.Shutdown()
}
Expand Down
2 changes: 1 addition & 1 deletion zrpc/internal/rpcserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestRpcServer(t *testing.T) {
grpcServer.GracefulStop()
lock.Unlock()

proc.WrapUp()
proc.Shutdown()
wgDone.Wait()
}

Expand Down

0 comments on commit c2ff008

Please sign in to comment.