Skip to content

Commit

Permalink
Merge PR #2274: simulation: Stop on SIGTERM
Browse files Browse the repository at this point in the history
  • Loading branch information
ValarDragon authored and cwgoes committed Sep 8, 2018
1 parent ffb4c5e commit c800bc7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 12 additions & 0 deletions x/mock/simulation/random_simulate_blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import (
"math"
"math/rand"
"os"
"os/signal"
"sort"
"syscall"
"testing"
"time"

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit c800bc7

Please sign in to comment.