feat: add Close method for resource cleanup in graceful shutdown (#16193)
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
This commit is contained in:
co-authored by
Aleksandr Bezobchuk
parent
46119d1384
commit
09ca393a19
+3
-1
@@ -2,6 +2,7 @@ package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
@@ -260,7 +261,7 @@ func startStandAlone(svrCtx *Context, appCreator types.AppCreator) error {
|
||||
// so we can gracefully stop the ABCI server.
|
||||
<-ctx.Done()
|
||||
svrCtx.Logger.Info("stopping the ABCI server...")
|
||||
return svr.Stop()
|
||||
return errors.Join(svr.Stop(), app.Close())
|
||||
})
|
||||
|
||||
return g.Wait()
|
||||
@@ -366,6 +367,7 @@ func startInProcess(svrCtx *Context, clientCtx client.Context, appCreator types.
|
||||
defer func() {
|
||||
if tmNode != nil && tmNode.IsRunning() {
|
||||
_ = tmNode.Stop()
|
||||
_ = app.Close()
|
||||
}
|
||||
|
||||
if traceWriterCleanup != nil {
|
||||
|
||||
@@ -58,6 +58,9 @@ type (
|
||||
|
||||
// Return the snapshot manager
|
||||
SnapshotManager() *snapshots.Manager
|
||||
|
||||
// Close is called in start cmd to gracefully cleanup resources.
|
||||
Close() error
|
||||
}
|
||||
|
||||
// AppCreator is a function that allows us to lazily initialize an
|
||||
|
||||
Reference in New Issue
Block a user