Skip to content

Commit

Permalink
Merge pull request #5426 from filecoin-project/chore/shutdown-server
Browse files Browse the repository at this point in the history
chore: shutdown server when receiving exit signal
hunjixin authored Oct 31, 2022

Verified

This commit was signed with the committer’s verified signature. The key has been revoked.
eggplants haruna
2 parents 5eb8361 + c466c18 commit 2f04338
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
@@ -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...")
@@ -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)

0 comments on commit 2f04338

Please sign in to comment.