go - Golang : gocraft/health package 100% CPU -
im using gocraft/health check health of service , have metrics of each endpoint. have problem: cpu reach 100% after 5 hours of starting service dont know why. without using "gocraft/health" takes 0,7% of cpu worked pack before
var stream = health.newstream() func main() { // log stdout! (can use writersink write log file, syslog, etc) stream.addsink(&health.writersink{os.stdout}) http.handlefunc("/api/getvastplayer", vastplayer) http.handlefunc("/static/", func(w http.responsewriter, r *http.request) { http.servefile(w, r, r.url.path[1:]) }) log.println("listening...") panic(http.listenandserve(":2001", nil)) }
;
func vastplayer(w http.responsewriter, r *http.request) { job_1 := stream.newjob("/api/getvastplayer") //job_2 := stream.newjob("/api/html/") sink := health.newjsonpollingsink(time.minute*5, time.minute*5) stream.addsink(sink) //http://creative.health.spoti.io/health adr:="127.0.0.1:5001" sink.startserver(adr) ...... ...... if bol{ job_1.complete(health.success) } else{ job_1.complete(health.validationerror) }
i think it's right code:
var stream = health.newstream() func main() { // log stdout! (can use writersink write log file, syslog, etc) stream.addsink(&health.writersink{os.stdout}) sink := health.newjsonpollingsink(time.minute*5, time.minute*5) stream.addsink(sink) //http://creative.health.spoti.io/health adr:="127.0.0.1:5001" sink.startserver(adr) http.handlefunc("/api/getvastplayer", vastplayer) http.handlefunc("/static/", func(w http.responsewriter, r *http.request) { http.servefile(w, r, r.url.path[1:]) }) log.println("listening...") panic(http.listenandserve(":2001", nil)) } func vastplayer(w http.responsewriter, r *http.request) { job_1 := stream.newjob("/api/getvastplayer") //job_2 := stream.newjob("/api/html/") ...... ...... if bol{ job_1.complete(health.success) } else{ job_1.complete(health.validationerror) } }
Comments
Post a Comment