Skip to content
Snippets Groups Projects
Select Git revision
  • 9696c8997cb785c5f0d8f1a98d7da74b56a83e7c
  • without_tipselection default
  • develop protected
  • fix/grafana-local-dashboard
  • wasp
  • fix/dashboard-explorer-freeze
  • master
  • feat/timerqueue
  • test/sync_debug_and_650
  • feat/sync_revamp_inv
  • wip/sync
  • tool/db-recovery
  • portcheck/fix
  • fix/synchronization
  • feat/new-dashboard-analysis
  • feat/refactored-analysis-dashboard
  • feat/new-analysis-dashboard
  • test/demo-prometheus-fpc
  • prometheus_metrics
  • wip/analysis-server
  • merge/fpc-test-value-transfer
  • v0.2.2
  • v0.2.1
  • v0.2.0
  • v0.1.3
  • v0.1.2
  • v0.1.1
  • v0.1.0
28 results

plugin.go

Blame
  • user avatar
    Acha Bill authored and GitHub committed
    * refactor plugins
    
    * fix fmt
    
    * fix compile err
    
    * fix errors
    
    * expose singletons via sync.once
    
    * re-disable remotelog and webauth plugins
    
    * re-enable autopeering plugin
    
    * Apply suggestions from code review
    
    * Apply suggestions from code review
    
    * add descriptive comments for getters
    
    Co-authored-by: default avatarLuca Moser <moser.luca@gmail.com>
    68fdcf49
    History
    plugin.go 1.19 KiB
    package profiling
    
    import (
    	"net/http"
    	"runtime"
    	"sync"
    
    	// import required to profile
    	_ "net/http/pprof"
    
    	"github.com/iotaledger/goshimmer/plugins/config"
    	"github.com/iotaledger/hive.go/logger"
    	"github.com/iotaledger/hive.go/node"
    	flag "github.com/spf13/pflag"
    )
    
    // PluginName is the name of the profiling plugin.
    const PluginName = "Profiling"
    
    var (
    	// plugin is the profiling plugin.
    	plugin *node.Plugin
    	once sync.Once
    	log    *logger.Logger
    )
    
    // CfgProfilingBindAddress defines the config flag of the profiling binding address.
    const CfgProfilingBindAddress = "profiling.bindAddress"
    
    // Plugin gets the plugin instance.
    func Plugin() *node.Plugin {
    	once.Do(func() {
    		plugin = node.NewPlugin(PluginName, node.Enabled, configure, run)
    	})
    	return plugin
    }
    
    func init() {
    	flag.String(CfgProfilingBindAddress, "127.0.0.1:6061", "bind address for the pprof server")
    }
    
    func configure(_ *node.Plugin) {
    	log = logger.NewLogger(PluginName)
    }
    
    func run(_ *node.Plugin) {
    	bindAddr := config.Node().GetString(CfgProfilingBindAddress)
    
    	runtime.SetMutexProfileFraction(5)
    	runtime.SetBlockProfileRate(5)
    
    	log.Infof("%s started, bind-address=%s", PluginName, bindAddr)
    	go http.ListenAndServe(bindAddr, nil)
    }