Created
February 16, 2018 13:05
-
-
Save DCRichards/39ed4d420d302eec46872b49883c9571 to your computer and use it in GitHub Desktop.
Golang profiling 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"net/http" | |
pp "net/http/pprof" | |
"time" | |
) | |
func main() { | |
mux := http.NewServeMux() | |
// Your existing routes here | |
const basePath = "/pprof" | |
mux.HandleFunc(basePath, pp.Index) | |
mux.HandleFunc(basePath+"/cmdline", pp.Cmdline) | |
mux.HandleFunc(basePath+"/profile", pp.Profile) | |
mux.HandleFunc(basePath+"/symbol", pp.Symbol) | |
mux.HandleFunc(basePath+"/trace", pp.Trace) | |
server := &http.Server{ | |
Addr: ":80", | |
Handler: mux, | |
ReadTimeout: 10 * time.Second, | |
WriteTimeout: 120 * time.Second, | |
} | |
log.Fatal(server.ListenAndServe()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment