mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-04 16:33:49 +08:00
add client pull loop + timeout
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"runtime"
|
"runtime"
|
||||||
@@ -109,21 +108,19 @@ func MessageQueue(ctx context.Context, network string) {
|
|||||||
var cfg config.ClientConfig
|
var cfg config.ClientConfig
|
||||||
cfg.Network = network
|
cfg.Network = network
|
||||||
ncutils.Log("pulling latest config for " + cfg.Network)
|
ncutils.Log("pulling latest config for " + cfg.Network)
|
||||||
var startTime float64
|
sleepTime := 2
|
||||||
startTime = 100
|
|
||||||
for {
|
for {
|
||||||
_, err := Pull(network, true)
|
_, err := Pull(network, true)
|
||||||
if err != nil {
|
if err == nil {
|
||||||
ncutils.Log(err.Error())
|
|
||||||
startTime = math.Log2(startTime * startTime)
|
|
||||||
} else {
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
sleepTime := int(startTime)
|
|
||||||
if sleepTime > 3600 {
|
if sleepTime > 3600 {
|
||||||
sleepTime = 3600
|
sleepTime = 3600
|
||||||
}
|
}
|
||||||
|
ncutils.Log("failed to pull for network " + network)
|
||||||
|
ncutils.Log(fmt.Sprintf("waiting %d seconds to retry...", sleepTime))
|
||||||
time.Sleep(time.Second * time.Duration(sleepTime))
|
time.Sleep(time.Second * time.Duration(sleepTime))
|
||||||
|
sleepTime = sleepTime * 2
|
||||||
}
|
}
|
||||||
time.Sleep(time.Second << 1)
|
time.Sleep(time.Second << 1)
|
||||||
cfg.ReadConfig()
|
cfg.ReadConfig()
|
||||||
|
Reference in New Issue
Block a user