Use pprof: https://golang.org/pkg/net/http/pprof/

Then, when it hangs, you can pull a traceback directly from your app and
see which goroutine is blocked, and exactly which line of code is the cause.

You can easily get stats with wget or curl:

http://localhost:6060/debug/pprof/goroutine?debug=2
http://localhost:6060/debug/pprof/goroutine?debug=1

This is assuming you're listening on port 6060; it doesn't matter what port
you use. Just only listen on localhost for security.

All you have to do is put this in your imports:
    _ "net/http/pprof"

And if your app is not already running a webserver you can add:
    go http.ListenAndServe("localhost:6060", nil)

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to