etcdmain: handle StopNotify when ErrStopped aborted publish
Fix
If a server starts and aborts due to config error,
it is possible to get stuck in ReadyNotify waits.
This adds select case to get notified on stop channel.
@@ -189,7 +189,10 @@ func startEtcd(cfg *embed.Config) (<-chan struct{}, <-chan error, error) {
return nil, nil, err
}
osutil.RegisterInterruptHandler(e.Server.Stop)
- <-e.Server.ReadyNotify() // wait for e.Server to join the cluster
+ select {
+ case <-e.Server.ReadyNotify(): // wait for e.Server to join the cluster
+ case <-e.Server.StopNotify(): // publish aborted from 'ErrStopped'
+ }
return e.Server.StopNotify(), e.Err(), nil
}
