better retry
This commit is contained in:
@@ -399,6 +399,10 @@ func (p *SyncedPool) AddRemote(host string) error {
|
|||||||
}()
|
}()
|
||||||
go func() {
|
go func() {
|
||||||
for range time.Tick(time.Second * 3) {
|
for range time.Tick(time.Second * 3) {
|
||||||
|
if !remote.IsHealthy() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Printf("Pinging remote %s\n", host)
|
||||||
err := remote.Ping()
|
err := remote.Ping()
|
||||||
|
|
||||||
for err != nil {
|
for err != nil {
|
||||||
|
|||||||
@@ -54,16 +54,25 @@ func NewPersistentConnection(address string) (*PersistentConnection, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *PersistentConnection) Connect() error {
|
func (m *PersistentConnection) Connect() error {
|
||||||
if !m.Dead {
|
fails := 0
|
||||||
|
for {
|
||||||
connection, err := net.Dial("tcp", m.address)
|
connection, err := net.Dial("tcp", m.address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error connecting to %s: %v\n", m.address, err)
|
log.Printf("Error connecting to %s: %v\n", m.address, err)
|
||||||
m.Died <- true
|
fails++
|
||||||
m.Dead = true
|
if fails > 15 {
|
||||||
return err
|
m.Died <- true
|
||||||
|
m.Dead = true
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m.Conn = connection
|
||||||
|
break
|
||||||
}
|
}
|
||||||
m.Conn = connection
|
time.Sleep(time.Millisecond * 300)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user