Merge PR #2274: simulation: Stop on SIGTERM

This commit is contained in:
Dev Ojha 2018-09-08 01:29:24 -07:00 committed by Christopher Goes
parent ffb4c5ec7d
commit c800bc7a1a
2 changed files with 13 additions and 0 deletions

View File

@ -114,5 +114,6 @@ BUG FIXES
* [ledger] [\#2064](https://github.com/cosmos/cosmos-sdk/issues/2064) Fix inability to sign and send transactions via the LCD by
loading a Ledger device at runtime.
* [\#2158](https://github.com/cosmos/cosmos-sdk/issues/2158) Fix non-deterministic ordering of validator iteration when slashing in `gov EndBlocker`
* [simulation] \#1924 Make simulation stop on SIGTERM
* Tendermint

View File

@ -6,7 +6,9 @@ import (
"math"
"math/rand"
"os"
"os/signal"
"sort"
"syscall"
"testing"
"time"
@ -76,6 +78,16 @@ func SimulateFromSeed(
header := abci.Header{Height: 0, Time: timestamp}
opCount := 0
// Setup code to catch SIGTERM's
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
go func() {
<-c
fmt.Printf("Exiting early due to SIGTERM, on block %d, operation %d\n", header.Height, opCount)
DisplayEvents(events)
os.Exit(128 + int(syscall.SIGTERM))
}()
var pastTimes []time.Time
var pastSigningValidators [][]abci.SigningValidator