diff --git a/supernode/cmd/start.go b/supernode/cmd/start.go index befaf85d..31c19b2a 100644 --- a/supernode/cmd/start.go +++ b/supernode/cmd/start.go @@ -3,9 +3,12 @@ package cmd import ( "context" "fmt" + "net/http" + _ "net/http/pprof" "os" "os/signal" "path/filepath" + "strings" "syscall" "github.com/LumeraProtocol/supernode/v2/p2p" @@ -139,6 +142,25 @@ The supernode will connect to the Lumera network and begin participating in the return fmt.Errorf("failed to create gateway server: %w", err) } + // Start profiling server on testnet only + isTestnet := strings.Contains(strings.ToLower(appConfig.LumeraClientConfig.ChainID), "testnet") + + if isTestnet { + profilingAddr := "0.0.0.0:6060" + + logtrace.Info(ctx, "Starting profiling server", logtrace.Fields{ + "address": profilingAddr, + "chain_id": appConfig.LumeraClientConfig.ChainID, + "is_testnet": isTestnet, + }) + + go func() { + if err := http.ListenAndServe(profilingAddr, nil); err != nil { + logtrace.Error(ctx, "Profiling server error", logtrace.Fields{"error": err.Error()}) + } + }() + } + // Start the services go func() { if err := RunServices(ctx, grpcServer, cService, *p2pService, gatewayServer); err != nil {