diff --git a/cmd/heph/root.go b/cmd/heph/root.go index 7f9a4a49..a6804e2d 100644 --- a/cmd/heph/root.go +++ b/cmd/heph/root.go @@ -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" @@ -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 @@ -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().String("http-pprof", "", "Http pprof address") plain = rootCmd.PersistentFlags().Bool("plain", false, "Plain output") rootCmd.PersistentFlags().Var(newWorkersValue(&workers), "workers", "Workers to spawn as a number or percentage") @@ -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 {