diff --git a/CHANGELOG.md b/CHANGELOG.md index 17dca0370ada..2c057767dc09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [#13046](https://github.com/cosmos/cosmos-sdk/pull/13046) Fix missing return statement in BaseApp.Query. * (store) [#13336](https://github.com/cosmos/cosmos-sdk/pull/13336) Call streaming listeners for deliver tx event, it was removed accidentally, backport #13334. * (grpc) [#13417](https://github.com/cosmos/cosmos-sdk/pull/13417) fix grpc query panic that could crash the node (backport #13352). +* (grpc) [#13418](https://github.com/cosmos/cosmos-sdk/pull/13418) Add close for grpc only mode. ## [v0.46.1](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.1) - 2022-08-24 diff --git a/server/start.go b/server/start.go index 722a77809a7e..68f40dcfea08 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) + } + }() } } @@ -486,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() } @@ -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...") }()