Skip to content

Commit

Permalink
add -pprof option
Browse files Browse the repository at this point in the history
  • Loading branch information
sentriz committed Dec 2, 2023
1 parent 32e0f30 commit 8163781
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/gonic/gonic.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"fmt"
"log"
"net/http"
"net/http/pprof"
"os"
"os/signal"
"path"
Expand Down Expand Up @@ -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)")
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 8163781

Please sign in to comment.