Skip to content

Instantly share code, notes, and snippets.

@patricklodder
Created March 23, 2021 20:24
Show Gist options
  • Save patricklodder/f47a1e5fd03ddaf1e29a83c81c181edf to your computer and use it in GitHub Desktop.
Save patricklodder/f47a1e5fd03ddaf1e29a83c81c181edf to your computer and use it in GitHub Desktop.
network status probe
diff --git a/main.go b/main.go
index fd397b0..5123269 100644
--- a/main.go
+++ b/main.go
@@ -189,6 +189,21 @@ func main() {
return server.Shutdown(ctx)
})
+ ticker := time.NewTicker(5 * time.Second)
+ quit := make(chan struct{})
+ go func() {
+ for {
+ select {
+ case <- ticker.C:
+ _, clienterr := client.NetworkStatus(ctx)
+ logger.Infow("client status", "err", clienterr)
+ case <- quit:
+ ticker.Stop()
+ return
+ }
+ }
+ }()
+
err = g.Wait()
// We always want to attempt to close the database, regardless of the error.
@patricklodder
Copy link
Author

apply with git apply add_net_status_probe.patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment