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) }  } 

ps: https://github.com/gocraft/health#jobs


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -