From 685200bc564e5d87dea45f5301675f13a60932b9 Mon Sep 17 00:00:00 2001 From: Daniil Lashin <3121312+danil-lashin@users.noreply.github.com> Date: Wed, 12 Feb 2020 14:39:14 +0300 Subject: [PATCH] Add pprof listen addr flag --- cmd/minter/cmd/node.go | 7 ++++++- cmd/minter/main.go | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/minter/cmd/node.go b/cmd/minter/cmd/node.go index 9337b9ea5..581a96a1e 100644 --- a/cmd/minter/cmd/node.go +++ b/cmd/minter/cmd/node.go @@ -47,11 +47,16 @@ func runNode(cmd *cobra.Command) error { } if pprofOn { + pprofAddr, err := cmd.Flags().GetString("pprof-addr") + if err != nil { + return err + } + pprofMux := http.DefaultServeMux http.DefaultServeMux = http.NewServeMux() go func() { logger.Error((&http.Server{ - Addr: "localhost:6060", + Addr: pprofAddr, Handler: pprofMux, }).ListenAndServe().Error()) }() diff --git a/cmd/minter/main.go b/cmd/minter/main.go index 0d2661abe..1e9bb82a6 100644 --- a/cmd/minter/main.go +++ b/cmd/minter/main.go @@ -19,6 +19,7 @@ func main() { rootCmd.PersistentFlags().StringVar(&utils.MinterHome, "home-dir", "", "base dir (default is $HOME/.minter)") rootCmd.PersistentFlags().StringVar(&utils.MinterConfig, "config", "", "path to config (default is $(home-dir)/config/config.toml)") rootCmd.PersistentFlags().Bool("pprof", false, "enable pprof") + rootCmd.PersistentFlags().String("pprof-addr", "0.0.0.0:6060", "pprof listen addr") if err := rootCmd.Execute(); err != nil { panic(err)