From 101a8a19c35be328c3903e672b6b8e7fe9aab682 Mon Sep 17 00:00:00 2001 From: Misha Nasledov Date: Tue, 15 Nov 2016 23:08:56 -0800 Subject: [PATCH] Make http healthcheck async --- red53_agent.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/red53_agent.go b/red53_agent.go index 908b042..e599889 100644 --- a/red53_agent.go +++ b/red53_agent.go @@ -196,11 +196,13 @@ func main() { sum += 2 } - http.HandleFunc("/healthcheck", func(w http.ResponseWriter, r *http.Request) { - fmt.Fprintf(w, "OK") - }) + go func() { + http.HandleFunc("/healthcheck", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "OK") + }) - log.Fatal(http.ListenAndServe(":8080", nil)) + log.Fatal(http.ListenAndServe(":8080", nil)) + }() // check regularly, specified by checkInterval ticker := time.NewTicker(checkInterval)