Browse Source

checkin on daemon start

Matthew R. Kasun 2 years ago
parent
commit
70fe3d0268
1 changed files with 4 additions and 1 deletions
  1. 4 1
      netclient/functions/mqpublish.go

+ 4 - 1
netclient/functions/mqpublish.go

@@ -26,13 +26,16 @@ import (
 func Checkin(ctx context.Context, wg *sync.WaitGroup) {
 func Checkin(ctx context.Context, wg *sync.WaitGroup) {
 	logger.Log(2, "starting checkin goroutine")
 	logger.Log(2, "starting checkin goroutine")
 	defer wg.Done()
 	defer wg.Done()
+	checkin()
+	ticker := time.NewTicker(time.Second * 60)
+	defer ticker.Stop()
 	for {
 	for {
 		select {
 		select {
 		case <-ctx.Done():
 		case <-ctx.Done():
 			logger.Log(0, "checkin routine closed")
 			logger.Log(0, "checkin routine closed")
 			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 <-ticker.C:
 			checkin()
 			checkin()
 		}
 		}
 	}
 	}