Skip to content

Commit

Permalink
fix: removed panic alert from graceful shutdown (dymensionxyz#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtsitrin authored Jun 1, 2023
1 parent b59ca6f commit bbd9f01
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
1 change: 1 addition & 0 deletions cmd/dymint/commands/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ func startInProcess(config *cfg.NodeConfig, tmConfig *tmcfg.Config, logger log.L

// Stop upon receiving SIGTERM or CTRL-C.
tmos.TrapSignal(logger, func() {
logger.Info("Caught SIGTERM. Exiting...")
if dymintNode.IsRunning() {
if err := dymintNode.Stop(); err != nil {
logger.Error("unable to stop the node", "error", err)
Expand Down
17 changes: 13 additions & 4 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"sync"

"github.com/libp2p/go-libp2p-core/crypto"
"go.uber.org/multierr"

llcfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/libs/log"
Expand Down Expand Up @@ -292,9 +291,19 @@ func (n *Node) GetGenesisChunks() ([]string, error) {
// OnStop is a part of Service interface.
func (n *Node) OnStop() {
err := n.dalc.Stop()
err = multierr.Append(err, n.settlementlc.Stop())
err = multierr.Append(err, n.P2P.Close())
n.Logger.Error("errors while stopping node:", "errors", err)
if err != nil {
n.Logger.Error("error while stopping data availability layer client", "error", err)
}

err = n.settlementlc.Stop()
if err != nil {
n.Logger.Error("error while stopping settlement layer client", "error", err)
}

err = n.P2P.Close()
if err != nil {
n.Logger.Error("error while stopping P2P client", "error", err)
}
}

// OnReset is a part of Service interface.
Expand Down
3 changes: 3 additions & 0 deletions p2p/gossip.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ func (g *Gossiper) Publish(ctx context.Context, data []byte) error {
func (g *Gossiper) ProcessMessages(ctx context.Context) {
for {
_, err := g.sub.Next(ctx)
if err == context.Canceled {
return
}
if err != nil {
g.logger.Error("failed to read message", "error", err)
return
Expand Down
3 changes: 2 additions & 1 deletion settlement/dymension/dymension.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,12 @@ func (d *HubClient) Start() error {

// Stop stops the HubClient.
func (d *HubClient) Stop() error {
d.cancel()
err := d.client.StopEventListener()
if err != nil {
return err
}
d.cancel()

return nil
}

Expand Down

0 comments on commit bbd9f01

Please sign in to comment.