mirror of
https://github.com/gravitl/netmaker.git
synced 2025-09-11 23:54:22 +08:00
added graceful wait for comms
This commit is contained in:
parent
d504e9e3cc
commit
8d63a8e058
1 changed files with 15 additions and 2 deletions
|
@ -47,12 +47,25 @@ func InitializeCommsNetwork() error {
|
|||
logger.Log(1, "comms net default acl is set incorrectly, please manually adjust to \"yes\",", COMMS_NETID)
|
||||
}
|
||||
}
|
||||
time.Sleep(time.Second << 1)
|
||||
SyncServerNetwork(COMMS_NETID)
|
||||
// gracefully check for comms interface
|
||||
gracefulCommsWait()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func gracefulCommsWait() {
|
||||
output, _ := ncutils.RunCmd("wg", false)
|
||||
starttime := time.Now()
|
||||
ifaceReady := strings.Contains(output, COMMS_NETID)
|
||||
for !ifaceReady && !(time.Now().After(starttime.Add(time.Second << 4))) {
|
||||
output, _ = ncutils.RunCmd("wg", false)
|
||||
SyncServerNetwork(COMMS_NETID)
|
||||
time.Sleep(time.Second)
|
||||
ifaceReady = strings.Contains(output, COMMS_NETID)
|
||||
}
|
||||
logger.Log(1, "comms network", COMMS_NETID, "ready")
|
||||
}
|
||||
|
||||
// SetJWTSecret - sets the jwt secret on server startup
|
||||
func setCommsID() {
|
||||
currentid, idErr := logic.FetchCommsNetID()
|
||||
|
|
Loading…
Add table
Reference in a new issue