mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-06 17:29:15 +08:00
made daemon only get networks once
This commit is contained in:
@@ -48,6 +48,7 @@ func Daemon() error {
|
|||||||
if len(networks) == 0 {
|
if len(networks) == 0 {
|
||||||
return errors.New("no networks")
|
return errors.New("no networks")
|
||||||
}
|
}
|
||||||
|
pubNetworks = append(pubNetworks, networks...)
|
||||||
// set ipforwarding on startup
|
// set ipforwarding on startup
|
||||||
err := local.SetIPForwarding()
|
err := local.SetIPForwarding()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -18,6 +18,9 @@ import (
|
|||||||
"github.com/gravitl/netmaker/tls"
|
"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
|
// 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
|
// if there are no updates, simply "pings" the server as a checkin
|
||||||
func Checkin(ctx context.Context, wg *sync.WaitGroup) {
|
func Checkin(ctx context.Context, wg *sync.WaitGroup) {
|
||||||
@@ -29,13 +32,7 @@ func Checkin(ctx context.Context, wg *sync.WaitGroup) {
|
|||||||
return
|
return
|
||||||
//delay should be configuraable -> use cfg.Node.NetworkSettings.DefaultCheckInInterval ??
|
//delay should be configuraable -> use cfg.Node.NetworkSettings.DefaultCheckInInterval ??
|
||||||
case <-time.After(time.Second * 60):
|
case <-time.After(time.Second * 60):
|
||||||
// logger.Log(0, "Checkin running")
|
for _, network := range pubNetworks {
|
||||||
//read latest config
|
|
||||||
networks, err := ncutils.GetSystemNetworks()
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
for _, network := range networks {
|
|
||||||
var nodeCfg config.ClientConfig
|
var nodeCfg config.ClientConfig
|
||||||
nodeCfg.Network = network
|
nodeCfg.Network = network
|
||||||
nodeCfg.ReadConfig()
|
nodeCfg.ReadConfig()
|
||||||
|
Reference in New Issue
Block a user