Skip to content
Snippets Groups Projects
Unverified Commit 8125d129 authored by Luca Moser's avatar Luca Moser Committed by GitHub
Browse files

normalize bind addresses prints (#400)

parent e8b6b9e5
No related branches found
No related tags found
No related merge requests found
...@@ -100,7 +100,7 @@ func worker(shutdownSignal <-chan struct{}) { ...@@ -100,7 +100,7 @@ func worker(shutdownSignal <-chan struct{}) {
stopped := make(chan struct{}) stopped := make(chan struct{})
bindAddr := config.Node.GetString(CfgBindAddress) bindAddr := config.Node.GetString(CfgBindAddress)
go func() { go func() {
log.Infof("Started %s: http://%s", PluginName, bindAddr) log.Infof("%s started, bind-address=%s", PluginName, bindAddr)
if err := server.Start(bindAddr); err != nil { if err := server.Start(bindAddr); err != nil {
if !errors.Is(err, http.ErrServerClosed) { if !errors.Is(err, http.ErrServerClosed) {
log.Errorf("Error serving: %s", err) log.Errorf("Error serving: %s", err)
......
...@@ -76,7 +76,7 @@ func start(shutdownSignal <-chan struct{}) { ...@@ -76,7 +76,7 @@ func start(shutdownSignal <-chan struct{}) {
// trigger start of the autopeering selection // trigger start of the autopeering selection
go func() { autopeering.StartSelection() }() go func() { autopeering.StartSelection() }()
log.Infof("%s started: Address=%s/%s", PluginName, localAddr.String(), localAddr.Network()) log.Infof("%s started, bind-address=%s", PluginName, localAddr.String())
<-shutdownSignal <-shutdownSignal
log.Info("Stopping " + PluginName + " ...") log.Info("Stopping " + PluginName + " ...")
......
...@@ -6,24 +6,33 @@ import ( ...@@ -6,24 +6,33 @@ import (
_ "net/http/pprof" _ "net/http/pprof"
"github.com/iotaledger/goshimmer/plugins/config" "github.com/iotaledger/goshimmer/plugins/config"
"github.com/iotaledger/hive.go/logger"
"github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/node"
flag "github.com/spf13/pflag" flag "github.com/spf13/pflag"
) )
// PluginName is the name of the profiling plugin.
const PluginName = "Profiling"
var ( var (
// Plugin is the profiling plugin. // Plugin is the profiling plugin.
Plugin = node.NewPlugin("Profiling", node.Enabled, configure, run) Plugin = node.NewPlugin(PluginName, node.Enabled, configure, run)
log *logger.Logger
) )
// CfgProfilingBindAddress defines the config flag of the profiling binding address. // CfgProfilingBindAddress defines the config flag of the profiling binding address.
const CfgProfilingBindAddress = "profiling.bindAddress" const CfgProfilingBindAddress = "profiling.bindAddress"
func init() { func init() {
flag.String(CfgProfilingBindAddress, "localhost:6061", "bind address for the pprof server") flag.String(CfgProfilingBindAddress, "127.0.0.1:6061", "bind address for the pprof server")
} }
func configure(_ *node.Plugin) {} func configure(_ *node.Plugin) {
log = logger.NewLogger(PluginName)
}
func run(_ *node.Plugin) { func run(_ *node.Plugin) {
go http.ListenAndServe(config.Node.GetString(CfgProfilingBindAddress), nil) bindAddr := config.Node.GetString(CfgProfilingBindAddress)
log.Infof("%s started, bind-address=%s", PluginName, bindAddr)
go http.ListenAndServe(bindAddr, nil)
} }
...@@ -47,7 +47,7 @@ func worker(shutdownSignal <-chan struct{}) { ...@@ -47,7 +47,7 @@ func worker(shutdownSignal <-chan struct{}) {
stopped := make(chan struct{}) stopped := make(chan struct{})
bindAddr := config.Node.GetString(CfgBindAddress) bindAddr := config.Node.GetString(CfgBindAddress)
go func() { go func() {
log.Infof("Started %s: http://%s", PluginName, bindAddr) log.Infof("%s started, bind-address=%s", PluginName, bindAddr)
if err := Server.Start(bindAddr); err != nil { if err := Server.Start(bindAddr); err != nil {
if !errors.Is(err, http.ErrServerClosed) { if !errors.Is(err, http.ErrServerClosed) {
log.Errorf("Error serving: %s", err) log.Errorf("Error serving: %s", err)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment