mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-23 17:51:39 +00:00
Unclean shutdown on SIGINT / SIGTERM (#3308)
* libs/common: TrapSignal accepts logger as a first parameter and does not block anymore * previously it was dumping "captured ..." msg to os.Stdout * TrapSignal should not be responsible for blocking thread of execution Refs #3238 * exit with zero (0) code upon receiving SIGTERM/SIGINT Refs #3238 * fix formatting in docs/app-dev/abci-cli.md Co-Authored-By: melekes <anton.kalyaev@gmail.com> * fix formatting in docs/app-dev/abci-cli.md Co-Authored-By: melekes <anton.kalyaev@gmail.com>
This commit is contained in:
committed by
Ethan Buchman
parent
41f91318e9
commit
cdf3a74f48
@ -4,14 +4,13 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/go-kit/kit/log/term"
|
||||
|
||||
cmn "github.com/tendermint/tendermint/libs/common"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
tmrpc "github.com/tendermint/tendermint/rpc/client"
|
||||
)
|
||||
@ -94,18 +93,12 @@ Examples:
|
||||
"broadcast_tx_"+broadcastTxMethod,
|
||||
)
|
||||
|
||||
// Quit when interrupted or received SIGTERM.
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||
go func() {
|
||||
for sig := range c {
|
||||
fmt.Printf("captured %v, exiting...\n", sig)
|
||||
for _, t := range transacters {
|
||||
t.Stop()
|
||||
}
|
||||
os.Exit(1)
|
||||
// Stop upon receiving SIGTERM or CTRL-C.
|
||||
cmn.TrapSignal(logger, func() {
|
||||
for _, t := range transacters {
|
||||
t.Stop()
|
||||
}
|
||||
}()
|
||||
})
|
||||
|
||||
// Wait until transacters have begun until we get the start time.
|
||||
timeStart := time.Now()
|
||||
|
Reference in New Issue
Block a user