Browse Source

stop rpc listeners in node.OnStop()

pull/426/head
Ethan Buchman 8 years ago
parent
commit
8192bb0aaf
2 changed files with 12 additions and 3 deletions
  1. +10
    -1
      node/node.go
  2. +2
    -2
      test/persist/test_failure_indices.sh

+ 10
- 1
node/node.go View File

@ -44,6 +44,7 @@ type Node struct {
genesisDoc *types.GenesisDoc
privKey crypto.PrivKeyEd25519
proxyApp proxy.AppConns
rpcListeners []net.Listener
}
func NewNodeDefault(config cfg.Config) *Node {
@ -208,10 +209,11 @@ func (n *Node) OnStart() error {
// Run the RPC server
if n.config.GetString("rpc_laddr") != "" {
_, err := n.startRPC()
listeners, err := n.startRPC()
if err != nil {
return err
}
n.rpcListeners = listeners
}
return nil
@ -230,6 +232,13 @@ func (n *Node) OnStop() {
log.Notice("Stopping Node")
// TODO: gracefully disconnect from peers.
n.sw.Stop()
for _, l := range n.rpcListeners {
log.Info("Closing rpc listener", "listener", l)
if err := l.Close(); err != nil {
log.Error("Error closing listener", "listener", l, "error", err)
}
}
}
// Add the event switch to reactors, mempool, etc.


+ 2
- 2
test/persist/test_failure_indices.sh View File

@ -45,8 +45,8 @@ function kill_procs(){
wait "$PID_TENDERMINT"
# wait for the ports to be released
wait_for_port 46656
wait_for_port 46657
#wait_for_port 46656
#wait_for_port 46657
}
# wait for port to be available


Loading…
Cancel
Save