Skip to content

Commit

Permalink
feat(api): Adding pprof handler
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Jun 3, 2021
1 parent f858ca5 commit ed3703c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/ketchup/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"embed"
"flag"
"net/http"
_ "net/http/pprof"
"os"
"strings"

Expand Down Expand Up @@ -63,6 +64,7 @@ func main() {

appServerConfig := server.Flags(fs, "")
promServerConfig := server.Flags(fs, "prometheus", flags.NewOverride("Port", 9090), flags.NewOverride("IdleTimeout", "10s"), flags.NewOverride("ShutdownTimeout", "5s"))
pprofServerConfig := server.Flags(fs, "pprof", flags.NewOverride("Port", 9999))
healthConfig := health.Flags(fs, "")

alcotestConfig := alcotest.Flags(fs, "")
Expand All @@ -88,6 +90,7 @@ func main() {

appServer := server.New(appServerConfig)
promServer := server.New(promServerConfig)
pprofServer := server.New(pprofServerConfig)
prometheusApp := prometheus.New(prometheusConfig)

ketchupDb, err := db.New(dbConfig)
Expand Down Expand Up @@ -149,6 +152,7 @@ func main() {

go promServer.Start("prometheus", healthApp.End(), prometheusApp.Handler())
go appServer.Start("http", healthApp.End(), httputils.Handler(appHandler, healthApp, recoverer.Middleware, prometheusApp.Middleware, owasp.New(owaspConfig).Middleware, cors.New(corsConfig).Middleware))
go pprofServer.Start("pprof", healthApp.End(), http.DefaultServeMux)

healthApp.WaitForTermination(appServer.Done())
server.GracefulWait(appServer.Done(), promServer.Done())
Expand Down

0 comments on commit ed3703c

Please sign in to comment.