Skip to content

Commit

Permalink
fix(golang): exit Go on signals; no more SIGKILL just to quit
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Jun 8, 2021
1 parent 7b05073 commit b5222b3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions golang/cosmos/daemon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package daemon
import (
"fmt"
"os"
"os/signal"
"syscall"

"github.com/cosmos/cosmos-sdk/server"
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
Expand Down Expand Up @@ -55,6 +57,14 @@ func Run() {

// RunWithController starts the app with a custom upcall handler.
func RunWithController(sendToController cmd.Sender) {
// Exit on several different signals.
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
go func() {
<-sigs
os.Exit(98)
}()

config := sdk.GetConfig()
SetConfigDefaults(config)
config.Seal()
Expand Down

0 comments on commit b5222b3

Please sign in to comment.