diff --git a/main.go b/main.go index 0516951834c0dd860cb88b9b6f09852cba4e2a85..68195928e6fe3df53b1639d20a4b30bbffa2b2b3 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,6 @@ package main import ( - "net/http" _ "net/http/pprof" "github.com/iotaledger/goshimmer/pluginmgr/core" @@ -13,8 +12,6 @@ import ( ) func main() { - go http.ListenAndServe("localhost:6061", nil) // pprof Server for Debbuging Mutexes - node.Run( core.PLUGINS, research.PLUGINS, diff --git a/pluginmgr/core/plugins.go b/pluginmgr/core/plugins.go index cb4692f76d4dcf5c0829a5240cd642f6f96364cc..ecb28954d9f9f640290d2f61b2e91c7ea5fac840 100644 --- a/pluginmgr/core/plugins.go +++ b/pluginmgr/core/plugins.go @@ -13,6 +13,7 @@ import ( "github.com/iotaledger/goshimmer/plugins/messagelayer" "github.com/iotaledger/goshimmer/plugins/metrics" "github.com/iotaledger/goshimmer/plugins/portcheck" + "github.com/iotaledger/goshimmer/plugins/profiling" "github.com/iotaledger/hive.go/node" ) @@ -23,6 +24,7 @@ var PLUGINS = node.Plugins( logger.PLUGIN, cli.PLUGIN, portcheck.PLUGIN, + profiling.Plugin, database.PLUGIN, autopeering.PLUGIN, messagelayer.PLUGIN, diff --git a/plugins/profiling/plugin.go b/plugins/profiling/plugin.go new file mode 100644 index 0000000000000000000000000000000000000000..6e82365051ee49d18b9efccae5957c56bbf54578 --- /dev/null +++ b/plugins/profiling/plugin.go @@ -0,0 +1,26 @@ +package profiling + +import ( + "net/http" + _ "net/http/pprof" + + "github.com/iotaledger/goshimmer/plugins/config" + "github.com/iotaledger/hive.go/node" + flag "github.com/spf13/pflag" +) + +var ( + Plugin = node.NewPlugin("Profiling", node.Enabled, configure, run) +) + +const CfgProfilingBindAddress = "profiling.bindAddress" + +func init() { + flag.String(CfgProfilingBindAddress, "localhost:6061", "bind address for the pprof server") +} + +func configure(_ *node.Plugin) {} + +func run(_ *node.Plugin) { + go http.ListenAndServe(config.Node.GetString(CfgProfilingBindAddress), nil) +}