Browse Source

Merge pull request #1127 from gravitl/refactor_v0.14.1_daemon_init_nets

made daemon only get networks once
Matthew R Kasun 3 years ago
parent
commit
8197728cad
2 changed files with 5 additions and 7 deletions
  1. 1 0
      netclient/functions/daemon.go
  2. 4 7
      netclient/functions/mqpublish.go

+ 1 - 0
netclient/functions/daemon.go

@@ -48,6 +48,7 @@ func Daemon() error {
 	if len(networks) == 0 {
 		return errors.New("no networks")
 	}
+	pubNetworks = append(pubNetworks, networks...)
 	// set ipforwarding on startup
 	err := local.SetIPForwarding()
 	if err != nil {

+ 4 - 7
netclient/functions/mqpublish.go

@@ -18,6 +18,9 @@ import (
 	"github.com/gravitl/netmaker/tls"
 )
 
+// pubNetworks hold the currently publishable networks
+var pubNetworks []string
+
 // Checkin  -- go routine that checks for public or local ip changes, publishes changes
 //   if there are no updates, simply "pings" the server as a checkin
 func Checkin(ctx context.Context, wg *sync.WaitGroup) {
@@ -29,13 +32,7 @@ func Checkin(ctx context.Context, wg *sync.WaitGroup) {
 			return
 			//delay should be configuraable -> use cfg.Node.NetworkSettings.DefaultCheckInInterval ??
 		case <-time.After(time.Second * 60):
-			// logger.Log(0, "Checkin running")
-			//read latest config
-			networks, err := ncutils.GetSystemNetworks()
-			if err != nil {
-				return
-			}
-			for _, network := range networks {
+			for _, network := range pubNetworks {
 				var nodeCfg config.ClientConfig
 				nodeCfg.Network = network
 				nodeCfg.ReadConfig()