mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 17:20:24 +08:00
chore: update restful/grpc servers shutdown stages (#3662)
This commit is contained in:
parent
00db97fcc1
commit
c2ff00883a
@ -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))
|
healthManager := health.NewHealthManager(fmt.Sprintf("%s-%s:%d", probeNamePrefix, host, port))
|
||||||
|
|
||||||
waitForCalled := proc.AddWrapUpListener(func() {
|
waitForCalled := proc.AddShutdownListener(func() {
|
||||||
healthManager.MarkNotReady()
|
healthManager.MarkNotReady()
|
||||||
if e := server.Shutdown(context.Background()); e != nil {
|
if e := server.Shutdown(context.Background()); e != nil {
|
||||||
logx.Error(e)
|
logx.Error(e)
|
||||||
|
@ -76,7 +76,7 @@ func (s *rpcServer) Start(register RegisterFn) error {
|
|||||||
|
|
||||||
// we need to make sure all others are wrapped up,
|
// we need to make sure all others are wrapped up,
|
||||||
// so we do graceful stop at shutdown phase instead of wrap up phase
|
// 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 {
|
if s.health != nil {
|
||||||
s.health.Shutdown()
|
s.health.Shutdown()
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ func TestRpcServer(t *testing.T) {
|
|||||||
grpcServer.GracefulStop()
|
grpcServer.GracefulStop()
|
||||||
lock.Unlock()
|
lock.Unlock()
|
||||||
|
|
||||||
proc.WrapUp()
|
proc.Shutdown()
|
||||||
wgDone.Wait()
|
wgDone.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user