Skip to content

Commit

Permalink
Enable http pprof
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelvigee committed Nov 27, 2023
1 parent ddbdfc4 commit c1f91b6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/heph/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"github.com/hephbuild/heph/utils/xstarlark"
"github.com/spf13/cobra"
"go.uber.org/multierr"
"net/http"
_ "net/http/pprof"
"os"
"runtime"
"runtime/pprof"
Expand All @@ -28,6 +30,7 @@ var cpuprofile *string
var memprofile *string
var shell *bool
var noCloudTelemetry *bool
var httpPprof *string
var noInline *bool
var printOutput boolStr
var catOutput boolStr
Expand Down Expand Up @@ -102,6 +105,7 @@ func init() {
summaryGen = rootCmd.PersistentFlags().Bool("summary-gen", false, "Prints execution stats, including during gen")
jaegerEndpoint = rootCmd.PersistentFlags().String("jaeger", "", "Jaeger endpoint to collect traces")
noCloudTelemetry = rootCmd.PersistentFlags().Bool("no-cloud-telemetry", false, "Disable cloud reporting")
httpPprof = rootCmd.PersistentFlags().Bool("http-pprof", false, "Enable http pprof")

Check failure on line 108 in cmd/heph/root.go

View workflow job for this annotation

GitHub Actions / Build

cannot use rootCmd.PersistentFlags().Bool("http-pprof", false, "Enable http pprof") (value of type *bool) as *string value in assignment

plain = rootCmd.PersistentFlags().Bool("plain", false, "Plain output")
rootCmd.PersistentFlags().Var(newWorkersValue(&workers), "workers", "Workers to spawn as a number or percentage")
Expand Down Expand Up @@ -173,6 +177,12 @@ var rootCmd = &cobra.Command{
}
}

if addr := *httpPprof; addr != "" {
go func() {
log.Error(http.ListenAndServe(addr, nil))
}()
}

return nil
},
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down

0 comments on commit c1f91b6

Please sign in to comment.