Skip to content

Commit 101a8a1

Browse files
committed
Make http healthcheck async
1 parent 6b3c7ad commit 101a8a1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

red53_agent.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,13 @@ func main() {
196196
sum += 2
197197
}
198198

199-
http.HandleFunc("/healthcheck", func(w http.ResponseWriter, r *http.Request) {
200-
fmt.Fprintf(w, "OK")
201-
})
199+
go func() {
200+
http.HandleFunc("/healthcheck", func(w http.ResponseWriter, r *http.Request) {
201+
fmt.Fprintf(w, "OK")
202+
})
202203

203-
log.Fatal(http.ListenAndServe(":8080", nil))
204+
log.Fatal(http.ListenAndServe(":8080", nil))
205+
}()
204206

205207
// check regularly, specified by checkInterval
206208
ticker := time.NewTicker(checkInterval)

0 commit comments

Comments
 (0)