From cbd96c0339ef381681aa1b2f2865df8f2fdabcf9 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Thu, 29 Sep 2022 09:31:29 +0800 Subject: [PATCH 1/3] add close for grpcOnly mode --- server/start.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/server/start.go b/server/start.go index beb51729b686..1d2272fd565c 100644 --- a/server/start.go +++ b/server/start.go @@ -417,13 +417,18 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App if err != nil { return err } - + defer grpcSrv.Stop() if config.GRPCWeb.Enable { grpcWebSrv, err = servergrpc.StartGRPCWeb(grpcSrv, config) if err != nil { ctx.Logger.Error("failed to start grpc-web http server: ", err) return err } + defer func() { + if err := grpcWebSrv.Close(); err != nil { + ctx.Logger.Error("failed to close grpc-web http server: ", err) + } + }() } } @@ -498,15 +503,6 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App _ = apiSrv.Close() } - if grpcSrv != nil { - grpcSrv.Stop() - if grpcWebSrv != nil { - if err := grpcWebSrv.Close(); err != nil { - ctx.Logger.Error("failed to close grpc-web http server: ", err) - } - } - } - ctx.Logger.Info("exiting...") }() From dbd4913dfa5d50f6e596412dbae701d1c0335c7c Mon Sep 17 00:00:00 2001 From: mmsqe Date: Thu, 29 Sep 2022 09:31:43 +0800 Subject: [PATCH 2/3] add tmNode nil check when exit --- server/start.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/start.go b/server/start.go index 1d2272fd565c..1cee1089d130 100644 --- a/server/start.go +++ b/server/start.go @@ -491,7 +491,7 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App } defer func() { - if tmNode.IsRunning() { + if tmNode != nil && tmNode.IsRunning() { _ = tmNode.Stop() } From 311c4a81e5e4f1ad8576b435a605919ceba16cf6 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Thu, 29 Sep 2022 18:23:34 +0800 Subject: [PATCH 3/3] add change log --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8b5ca65b4d4..7de6291c85d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -174,6 +174,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (Store) [#13334](https://github.com/cosmos/cosmos-sdk/pull/13334) Call streaming listeners for deliver tx event, it was removed accidentally. * (grpc) [#13352](https://github.com/cosmos/cosmos-sdk/pull/13352) fix grpc query panic that could crash the node. * (snapshot) [#13400](https://github.com/cosmos/cosmos-sdk/pull/13400) Fix snapshot checksum issue in golang 1.19. +* (grpc) [#13418](https://github.com/cosmos/cosmos-sdk/pull/13418) Add close for grpc only mode. ### Deprecated