better retry
All checks were successful
Build and Publish / BuildAndDeployAmd64 (push) Successful in 27s
Build and Publish / BuildAndDeploy (push) Successful in 2m15s

This commit is contained in:
matst80
2024-11-13 10:19:56 +01:00
parent 73b1616d4b
commit 589a7c159b
2 changed files with 18 additions and 5 deletions

View File

@@ -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 {

View File

@@ -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
} }