From 816378140eab6bedad903629fdb918db6fb2be40 Mon Sep 17 00:00:00 2001 From: sentriz Date: Sat, 2 Dec 2023 17:03:35 +0000 Subject: [PATCH] add -pprof option --- cmd/gonic/gonic.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmd/gonic/gonic.go b/cmd/gonic/gonic.go index 237840d9..cf4bd691 100644 --- a/cmd/gonic/gonic.go +++ b/cmd/gonic/gonic.go @@ -9,6 +9,7 @@ import ( "fmt" "log" "net/http" + "net/http/pprof" "os" "os/signal" "path" @@ -87,6 +88,7 @@ func main() { set.Var(&confMultiValueArtist, "multi-value-artist", "setting for mutli-valued track artist scanning (optional)") set.Var(&confMultiValueAlbumArtist, "multi-value-album-artist", "setting for mutli-valued album artist scanning (optional)") + confPprof := set.Bool("pprof", false, "enable the /debug/pprof endpoint (optional)") confExpvar := set.Bool("expvar", false, "enable the /debug/vars endpoint (optional)") deprecatedConfGenreSplit := set.String("genre-split", "", "(deprecated, see multi-value settings)") @@ -283,6 +285,14 @@ func main() { })) } + if *confPprof { + 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) + } + errgrp, ctx := errgroup.WithContext(context.Background()) errgrp.Go(func() error {