|
@@ -121,32 +121,32 @@ func MessageQueue(ctx context.Context, network string) {
|
|
|
ncutils.Log("netclient go routine started for " + network)
|
|
|
var cfg config.ClientConfig
|
|
|
cfg.Network = network
|
|
|
- //var configPath = fmt.Sprintf("%snetconfig-%s", ncutils.GetNetclientPathSpecific(), network)
|
|
|
- //fileInfo, err := os.Stat(configPath)
|
|
|
- //if err != nil {
|
|
|
- // ncutils.Log("could not stat config file: " + configPath)
|
|
|
- //}
|
|
|
+ var configPath = fmt.Sprintf("%snetconfig-%s", ncutils.GetNetclientPathSpecific(), network)
|
|
|
+ fileInfo, err := os.Stat(configPath)
|
|
|
+ if err != nil {
|
|
|
+ ncutils.Log("could not stat config file: " + configPath)
|
|
|
+ }
|
|
|
// speed up UDP rest
|
|
|
- // if time.Now().After(fileInfo.ModTime().Add(time.Minute)) {
|
|
|
- // sleepTime := 2
|
|
|
- // ncutils.Log("pulling latest config for " + cfg.Network)
|
|
|
- // for {
|
|
|
- // _, err := Pull(network, true)
|
|
|
- // if err == nil {
|
|
|
- // break
|
|
|
- // } else {
|
|
|
- // ncutils.PrintLog("error pulling config for "+network+": "+err.Error(), 1)
|
|
|
- // }
|
|
|
- // if 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))
|
|
|
- // sleepTime = sleepTime * 2
|
|
|
- // }
|
|
|
- // }
|
|
|
- //time.Sleep(time.Second << 1)
|
|
|
+ if time.Now().After(fileInfo.ModTime().Add(time.Minute)) {
|
|
|
+ sleepTime := 2
|
|
|
+ ncutils.Log("pulling latest config for " + cfg.Network)
|
|
|
+ for {
|
|
|
+ _, err := Pull(network, true)
|
|
|
+ if err == nil {
|
|
|
+ break
|
|
|
+ } else {
|
|
|
+ ncutils.PrintLog("error pulling config for "+network+": "+err.Error(), 1)
|
|
|
+ }
|
|
|
+ if 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))
|
|
|
+ sleepTime = sleepTime * 2
|
|
|
+ }
|
|
|
+ }
|
|
|
+ time.Sleep(time.Second << 1)
|
|
|
cfg.ReadConfig()
|
|
|
ncutils.Log("daemon started for network: " + network)
|
|
|
client := SetupMQTT(&cfg)
|