concurrent shutdown

This commit is contained in:
Ethan Buchman
2016-02-03 02:15:33 -05:00
parent 0825aa5d64
commit 8b735b36be
3 changed files with 16 additions and 2 deletions

View File

@@ -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

View File

@@ -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()
}
//-----------------------------------------------------------

View File

@@ -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