Skip to content

Commit

Permalink
Add pprof listen addr flag
Browse files Browse the repository at this point in the history
  • Loading branch information
danil-lashin committed Feb 12, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent d0e4ea9 commit 685200b
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmd/minter/cmd/node.go
Original file line number Diff line number Diff line change
@@ -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())
}()
1 change: 1 addition & 0 deletions cmd/minter/main.go
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 685200b

Please sign in to comment.