mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-05 00:43:58 +08:00
do checkin after mq is connected, publish metrics only when node is connected
This commit is contained in:
@@ -68,12 +68,14 @@ func Daemon() error {
|
|||||||
cancel()
|
cancel()
|
||||||
logger.Log(0, "shutting down netclient daemon")
|
logger.Log(0, "shutting down netclient daemon")
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
mqclient.Disconnect(250)
|
||||||
logger.Log(0, "shutdown complete")
|
logger.Log(0, "shutdown complete")
|
||||||
return nil
|
return nil
|
||||||
case <-reset:
|
case <-reset:
|
||||||
logger.Log(0, "received reset")
|
logger.Log(0, "received reset")
|
||||||
cancel()
|
cancel()
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
mqclient.Disconnect(250)
|
||||||
logger.Log(0, "restarting daemon")
|
logger.Log(0, "restarting daemon")
|
||||||
cancel = startGoRoutines(&wg)
|
cancel = startGoRoutines(&wg)
|
||||||
}
|
}
|
||||||
@@ -109,7 +111,14 @@ func startGoRoutines(wg *sync.WaitGroup) context.CancelFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
for {
|
||||||
|
if mqclient != nil && mqclient.IsConnected() {
|
||||||
go Checkin(ctx, wg)
|
go Checkin(ctx, wg)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
}
|
||||||
|
|
||||||
return cancel
|
return cancel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -107,7 +107,7 @@ func checkin() {
|
|||||||
config.Write(&nodeCfg, nodeCfg.Network)
|
config.Write(&nodeCfg, nodeCfg.Network)
|
||||||
}
|
}
|
||||||
Hello(&nodeCfg)
|
Hello(&nodeCfg)
|
||||||
if nodeCfg.Server.Is_EE {
|
if nodeCfg.Server.Is_EE && nodeCfg.Node.Connected == "yes" {
|
||||||
logger.Log(0, "collecting metrics for node", nodeCfg.Node.Name)
|
logger.Log(0, "collecting metrics for node", nodeCfg.Node.Name)
|
||||||
publishMetrics(&nodeCfg)
|
publishMetrics(&nodeCfg)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user