retry and better logs
This commit is contained in:
@@ -363,17 +363,23 @@ func (p *SyncedPool) removeLocalGrain(id CartId) {
|
||||
func (p *SyncedPool) AddRemote(host string) {
|
||||
|
||||
_, hasHost := p.remotes[host]
|
||||
if host == "" || hasHost {
|
||||
if host == "" || hasHost || host == p.Hostname {
|
||||
return
|
||||
}
|
||||
// if host == "" || hasHost || host == p.Hostname {
|
||||
// return
|
||||
// }
|
||||
|
||||
client := NewConnection(fmt.Sprintf("%s:1338", host))
|
||||
r, err := client.Call(Ping, nil)
|
||||
var r *FrameWithPayload
|
||||
var err error
|
||||
pings := 3
|
||||
for pings >= 0 {
|
||||
r, err = client.Call(Ping, nil)
|
||||
if err != nil {
|
||||
log.Printf("Error connecting to remote %s: %s\n", host, err)
|
||||
return
|
||||
log.Printf("Ping failed when adding %s, trying %d more times\n", host, pings)
|
||||
pings--
|
||||
time.Sleep(time.Millisecond * 300)
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
log.Printf("Connected to remote %s: %v\n", host, r)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user