mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-09 13:26:52 +08:00
add client pull loop + timeout
This commit is contained in:
parent
d2467e13f3
commit
8e82bfa607
1 changed files with 16 additions and 4 deletions
|
@ -5,6 +5,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
@ -108,10 +109,21 @@ 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)
|
||||||
_, err := Pull(network, true)
|
var startTime float64
|
||||||
if err != nil {
|
startTime = 2
|
||||||
ncutils.Log(err.Error())
|
for {
|
||||||
return
|
_, err := Pull(network, true)
|
||||||
|
if err != nil {
|
||||||
|
ncutils.Log(err.Error())
|
||||||
|
startTime = math.Log(startTime * startTime)
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
sleepTime := int(startTime)
|
||||||
|
if sleepTime > 3600 {
|
||||||
|
sleepTime = 3600
|
||||||
|
}
|
||||||
|
time.Sleep(time.Second * time.Duration(sleepTime))
|
||||||
}
|
}
|
||||||
time.Sleep(time.Second << 1)
|
time.Sleep(time.Second << 1)
|
||||||
cfg.ReadConfig()
|
cfg.ReadConfig()
|
||||||
|
|
Loading…
Add table
Reference in a new issue