Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move pprof from pprof.go to root.go
  • Loading branch information
Valery Piashchynski committed Feb 11, 2020
commit c1a227d465e857bbf4ba2f5f686aadb9b6b8d348
38 changes: 0 additions & 38 deletions cmd/rr/cmd/pprof.go

This file was deleted.

24 changes: 24 additions & 0 deletions cmd/rr/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import (
"github.com/spiral/roadrunner/cmd/util"
"github.com/spiral/roadrunner/service"
"github.com/spiral/roadrunner/service/limit"
"log"
"net/http"
"net/http/pprof"
"os"
)

Expand Down Expand Up @@ -116,8 +119,29 @@ func init() {
})
}
}

// if debug --> also run pprof service
if Debug {
go runDebugServer()
}
})
}
func runDebugServer() {
mux := http.NewServeMux()
mux.HandleFunc("/debug/pprof/", pprof.Index)
mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline)
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
srv := http.Server{
Addr: ":6061",
Handler: mux,
}

if err := srv.ListenAndServe(); err != nil {
log.Fatal(err)
}
}

func configureLogger(format string) {
util.Colorize = false
Expand Down