Skip to content

Commit

Permalink
chore: shutdown server when receiving exit signal
Browse files Browse the repository at this point in the history
  • Loading branch information
simlecode committed Oct 28, 2022
1 parent 5eb8361 commit c466c18
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,9 @@ func (node *Node) Stop(ctx context.Context) {
log.Infof("shutting down pay channel...")
node.paychan.Stop()

// Stop market submodule
// node.market.Stop()

log.Infof("closing repository...")
if err := node.repo.Close(); err != nil {
fmt.Printf("error closing repo: %s\n", err)
log.Warnf("error closing repo: %s", err)
}

log.Infof("flushing system logs...")
Expand Down Expand Up @@ -302,10 +299,13 @@ func (node *Node) RunRPCAndWait(ctx context.Context, rootCmdDaemon *cmds.Command
// todo: design an genterfull
memguard.CatchSignal(func(signal os.Signal) {
log.Infof("received signal(%s), venus will shutdown...", signal.String())
log.Infof("shutting down server...")
if err := apiserv.Shutdown(ctx); err != nil {
log.Warnf("failed to shutdown server: %v", err)
}
node.Stop(ctx)
log.Infof("venus shutdown gracefully ...")
_ = log.Sync()
memguard.Purge()
log.Infof("venus shutdown gracefully ...")
terminate <- nil
}, syscall.SIGTERM, os.Interrupt)

Expand Down

0 comments on commit c466c18

Please sign in to comment.