I am using _“net/http/pprof” for profiling.
I am able to do profiling on localhost. at port :6060 but not on production.
I am using Heroku. If my link is abc.herokuapp.com Then what to change for the following lines.
go func() {
log.Println(http.ListenAndServe(“localhost:6060”, nil))
}()
If you want to profile a program running on another machine, replace the word localhost with the DNS name or IP address of the machine that the program is running on.
Depending on where that machine is, you may have to adjust firewall rules to permit traffic to port 6060.
how to change the port your Go application is listening on
or, how to open an additional port for your Go application to listen on.
Which do you want to do?
It might be easier if you can post a small sample program which runs in your heroku account, we can guide you on how to modify it to allow remote profiling. Then you can apply that knowledge to your real program.
Ok, let’s strip this problem down[quote=“PR101, post:5, topic:5311”]
// Main problem occurs here
go func() {
log.Println(http.ListenAndServe(“abc.herokuapp.com:6060”, nil))
}()
[/quote]
The problem with this part of the code is the ListenAndServe will run in another goroutine, while allowing the main goroutine to exit, terminating the program.