From 8b735b36be4a99ebabe007bf3edd57453e8b8578 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Wed, 3 Feb 2016 02:15:33 -0500 Subject: [PATCH] concurrent shutdown --- README.md | 8 ++++++++ handlers/handlers.go | 8 +++++++- types/val.go | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 53e0fa225..6c686da23 100644 --- a/README.md +++ b/README.md @@ -37,3 +37,11 @@ The chain's rpc can be found at http://localhost:46657. The netmon expects a config file with a list of chains/validators to get started. A default one for a local chain is provided as local-chain.json. `netmon config` can be used to create a config file for a chain deployed with `mintnet`. The API is available as GET requests with URI encoded parameters, or as JSONRPC POST requests. The JSONRPC methods are also exposed over websocket. + +# TODO + +- log metrics for charts +- mintnet rpc commands +- chain size +- val set changes +- more efficient locking / refactor for a big select loop diff --git a/handlers/handlers.go b/handlers/handlers.go index ada84381e..743acb912 100644 --- a/handlers/handlers.go +++ b/handlers/handlers.go @@ -49,11 +49,17 @@ func NewTendermintNetwork() *TendermintNetwork { func (tn *TendermintNetwork) Stop() { tn.mtx.Lock() defer tn.mtx.Unlock() + wg := new(sync.WaitGroup) for _, c := range tn.Chains { for _, v := range c.Config.Validators { - v.Stop() + wg.Add(1) + go func(val *types.ValidatorState) { + val.Stop() + wg.Done() + }(v) } } + wg.Wait() } //----------------------------------------------------------- diff --git a/types/val.go b/types/val.go index 6cc81e35b..034c6f37f 100644 --- a/types/val.go +++ b/types/val.go @@ -69,7 +69,7 @@ func (vs *ValidatorState) Start() error { vs.Config.mtx.Unlock() em := eventmeter.NewEventMeter(fmt.Sprintf("ws://%s/websocket", rpcAddr), UnmarshalEvent) - if err := em.Start(); err != nil { + if _, err := em.Start(); err != nil { return err } vs.em = em