diff --git a/gateway/gateway.go b/gateway/gateway.go index b3a9baf..daec068 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -293,14 +293,16 @@ func (g *Gateway) handleWS(stop <-chan struct{}) { select { case <-stop: return - case <-g.paceDeath: - // Pacemaker died, pretty fatal. We'll reconnect though. - if err := g.Reconnect(); err != nil { - // Very fatal if this fails. We'll warn the user. - g.FatalLog(errors.Wrap(err, "Failed to reconnect")) + case err := <-g.paceDeath: + if err != nil { + // Pacemaker died, pretty fatal. We'll reconnect though. + if err := g.Reconnect(); err != nil { + // Very fatal if this fails. We'll warn the user. + g.FatalLog(errors.Wrap(err, "Failed to reconnect")) - // Then, we'll take the safe way and exit. - return + // Then, we'll take the safe way and exit. + return + } } case ev := <-ch: diff --git a/gateway/pacemaker.go b/gateway/pacemaker.go index 395bb41..66511ce 100644 --- a/gateway/pacemaker.go +++ b/gateway/pacemaker.go @@ -86,9 +86,7 @@ func (p *Pacemaker) start(stop chan struct{}) error { p.SentBeat = time.Now() if p.Dead() { - if err := p.OnDead(); err != nil { - return err - } + return ErrDead } } }