Skip to content

Commit

Permalink
register handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
kamaev committed Nov 30, 2017
1 parent 1806ef5 commit 0cea50d
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions cmd/profile.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
package cmd

import (
"github.com/moira-alert/moira"
"net/http"
_ "net/http/pprof"
"net/http/pprof"

"github.com/moira-alert/moira"
)

// StartProfiling starts http server with profiling data at given port
func StartProfiling(logger moira.Logger, config ProfilerConfig) {

pprofMux := http.NewServeMux()
pprofMux.HandleFunc("/debug/pprof/", pprof.Index)
pprofMux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
pprofMux.HandleFunc("/debug/pprof/profile", pprof.Profile)
pprofMux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
pprofMux.HandleFunc("/debug/pprof/trace", pprof.Trace)

go func() {
err := http.ListenAndServe(config.Port, nil)
err := http.ListenAndServe(config.Port, pprofMux)
if err != nil {
logger.Infof("Can't start pprof server: %v", err)
return
}
}()

}

0 comments on commit 0cea50d

Please sign in to comment.