[tm-bench] exit on CTRL-C (#2405)

This commit is contained in:
bradyjoestar 2018-10-08 00:06:01 -07:00 committed by Anton Kaliaev
parent b8556b97b8
commit 4c0c6e0116
1 changed files with 15 additions and 0 deletions

View File

@ -12,6 +12,8 @@ import (
"github.com/tendermint/tendermint/libs/log"
tmrpc "github.com/tendermint/tendermint/rpc/client"
"os/signal"
"syscall"
)
var logger = log.NewNopLogger()
@ -101,6 +103,19 @@ Examples:
"broadcast_tx_"+broadcastTxMethod,
)
//catch Interrupt and quit tm-bench
go func() {
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
for sig := range c {
fmt.Printf("captured %v, exiting...\n", sig)
for _, t := range transacters {
t.Stop()
}
os.Exit(1)
}
}()
// Wait until transacters have begun until we get the start time
timeStart := time.Now()
logger.Info("Time last transacter started", "t", timeStart)