()
| 134 | } |
| 135 | |
| 136 | func diagnosticLoop() { |
| 137 | defer func() { |
| 138 | panichandler.PanicHandler("diagnosticLoop", recover()) |
| 139 | }() |
| 140 | if os.Getenv("WAVETERM_NOPING") != "" { |
| 141 | log.Printf("WAVETERM_NOPING set, disabling diagnostic ping\n") |
| 142 | return |
| 143 | } |
| 144 | var lastSentDate string |
| 145 | time.Sleep(InitialDiagnosticWait) |
| 146 | for { |
| 147 | currentDate := time.Now().Format("2006-01-02") |
| 148 | if lastSentDate == "" || lastSentDate != currentDate { |
| 149 | if sendDiagnosticPing() { |
| 150 | lastSentDate = currentDate |
| 151 | } |
| 152 | } |
| 153 | time.Sleep(DiagnosticTick) |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | func sendDiagnosticPing() bool { |
| 158 | ctx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second) |
no test coverage detected