Expose pprof debug HTTP API when desired on web/daemon/api
This commit is contained in:
parent
02b0a0abde
commit
cc71510d8d
|
@ -25,6 +25,7 @@ import (
|
|||
"log"
|
||||
"math"
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
"net/netip"
|
||||
"net/url"
|
||||
"os"
|
||||
|
@ -44,11 +45,14 @@ func encodeJson(r *http.Request, d any) ([]byte, error) {
|
|||
}
|
||||
|
||||
func main() {
|
||||
log.SetFlags(log.Ldate | log.Ltime | log.Lmicroseconds)
|
||||
|
||||
torHost := os.Getenv("TOR_SERVICE_ADDRESS")
|
||||
moneroHost := flag.String("host", "127.0.0.1", "IP address of your Monero node")
|
||||
moneroRpcPort := flag.Uint("rpc-port", 18081, "monerod RPC API port number")
|
||||
dbString := flag.String("db", "", "")
|
||||
p2poolApiHost := flag.String("api-host", "", "Host URL for p2pool go observer consensus")
|
||||
debugListen := flag.String("debug-listen", "", "Provide a bind address and port to expose a pprof HTTP API on it.")
|
||||
flag.Parse()
|
||||
|
||||
client.SetDefaultClientSettings(fmt.Sprintf("http://%s:%d", *moneroHost, *moneroRpcPort))
|
||||
|
@ -1745,6 +1749,14 @@ func main() {
|
|||
}),
|
||||
}
|
||||
|
||||
if *debugListen != "" {
|
||||
go func() {
|
||||
if err := http.ListenAndServe(*debugListen, nil); err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
if err := server.ListenAndServe(); err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ import (
|
|||
"git.gammaspectra.live/P2Pool/p2pool-observer/types"
|
||||
"git.gammaspectra.live/P2Pool/p2pool-observer/utils"
|
||||
"log"
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
@ -27,12 +29,15 @@ func blockId(b *sidechain.PoolBlock) types.Hash {
|
|||
var sideBlocksLock sync.RWMutex
|
||||
|
||||
func main() {
|
||||
log.SetFlags(log.Ldate | log.Ltime | log.Lmicroseconds)
|
||||
|
||||
moneroHost := flag.String("host", "127.0.0.1", "IP address of your Monero node")
|
||||
moneroRpcPort := flag.Uint("rpc-port", 18081, "monerod RPC API port number")
|
||||
startFromHeight := flag.Uint64("from", 0, "Start sync from this height")
|
||||
dbString := flag.String("db", "", "")
|
||||
p2poolApiHost := flag.String("api-host", "", "Host URL for p2pool go observer consensus")
|
||||
fullMode := flag.Bool("full-mode", false, "Allocate RandomX dataset, uses 2GB of RAM")
|
||||
debugListen := flag.String("debug-listen", "", "Provide a bind address and port to expose a pprof HTTP API on it.")
|
||||
flag.Parse()
|
||||
|
||||
client.SetDefaultClientSettings(fmt.Sprintf("http://%s:%d", *moneroHost, *moneroRpcPort))
|
||||
|
@ -278,6 +283,14 @@ func main() {
|
|||
}
|
||||
}()
|
||||
|
||||
if *debugListen != "" {
|
||||
go func() {
|
||||
if err := http.ListenAndServe(*debugListen, nil); err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
for range time.Tick(time.Second * 1) {
|
||||
currentTip := indexDb.GetSideBlockTip()
|
||||
currentMainTip := indexDb.GetMainBlockTip()
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
pprofHttp "net/http/pprof"
|
||||
_ "net/http/pprof"
|
||||
"net/netip"
|
||||
"os"
|
||||
"os/signal"
|
||||
|
@ -61,9 +61,11 @@ func main() {
|
|||
blockCache := flag.String("block-cache", "p2pool.cache", "Block cache for faster startups. Set to empty to disable")
|
||||
|
||||
//testing settings
|
||||
doDebug := flag.Bool("debug", false, "Log more details, profile performance over API. Default false")
|
||||
doDebug := flag.Bool("debug", false, "Log more details. Default false")
|
||||
ipv6Only := flag.Bool("ipv6-only", false, "Use only IPv6. Default false")
|
||||
|
||||
debugListen := flag.String("debug-listen", "", "Provide a bind address and port to expose a pprof HTTP API on it.")
|
||||
|
||||
//TODO extend verbosity to debug flag
|
||||
flag.Parse()
|
||||
|
||||
|
@ -144,14 +146,6 @@ func main() {
|
|||
|
||||
serveMux := getServerMux(instance)
|
||||
|
||||
if *doDebug {
|
||||
serveMux.PathPrefix("/debug/pprof/").HandlerFunc(pprofHttp.Index)
|
||||
serveMux.HandleFunc("/debug/pprof/cmdline", pprofHttp.Cmdline)
|
||||
serveMux.HandleFunc("/debug/pprof/profile", pprofHttp.Profile)
|
||||
serveMux.HandleFunc("/debug/pprof/symbol", pprofHttp.Symbol)
|
||||
serveMux.HandleFunc("/debug/pprof/trace", pprofHttp.Trace)
|
||||
}
|
||||
|
||||
server := &http.Server{
|
||||
Addr: *apiBind,
|
||||
ReadTimeout: time.Second * 2,
|
||||
|
@ -176,6 +170,14 @@ func main() {
|
|||
}()
|
||||
}
|
||||
|
||||
if *debugListen != "" {
|
||||
go func() {
|
||||
if err := http.ListenAndServe(*debugListen, nil); err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
var connectList []netip.AddrPort
|
||||
for _, peerAddr := range strings.Split(*addPeers, ",") {
|
||||
if peerAddr == "" {
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
utils2 "git.gammaspectra.live/P2Pool/p2pool-observer/cmd/utils"
|
||||
"git.gammaspectra.live/P2Pool/p2pool-observer/index"
|
||||
|
@ -27,6 +28,7 @@ import (
|
|||
"log"
|
||||
"math"
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
"net/netip"
|
||||
"net/url"
|
||||
"os"
|
||||
|
@ -144,7 +146,16 @@ func toFloat64(t any) float64 {
|
|||
}
|
||||
|
||||
func main() {
|
||||
client.SetDefaultClientSettings(os.Getenv("MONEROD_RPC_URL"))
|
||||
|
||||
log.SetFlags(log.Ldate | log.Ltime | log.Lmicroseconds)
|
||||
|
||||
//monerod related
|
||||
moneroHost := flag.String("host", "127.0.0.1", "IP address of your Monero node")
|
||||
moneroRpcPort := flag.Uint("rpc-port", 18081, "monerod RPC API port number")
|
||||
debugListen := flag.String("debug-listen", "", "Provide a bind address and port to expose a pprof HTTP API on it.")
|
||||
flag.Parse()
|
||||
|
||||
client.SetDefaultClientSettings(fmt.Sprintf("http://%s:%d", *moneroHost, *moneroRpcPort))
|
||||
torHost := os.Getenv("TOR_SERVICE_ADDRESS")
|
||||
env := twig.New(&loader{})
|
||||
|
||||
|
@ -1641,6 +1652,14 @@ func main() {
|
|||
}),
|
||||
}
|
||||
|
||||
if *debugListen != "" {
|
||||
go func() {
|
||||
if err := http.ListenAndServe(*debugListen, nil); err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
if err := server.ListenAndServe(); err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
|
|
|
@ -151,7 +151,6 @@ services:
|
|||
- GOPROXY=${GOPROXY}
|
||||
restart: always
|
||||
environment:
|
||||
- MONEROD_RPC_URL=http://${MONEROD_HOST}:${MONEROD_RPC_PORT}
|
||||
- TOR_SERVICE_ADDRESS=${TOR_SERVICE_ADDRESS}
|
||||
- NET_SERVICE_ADDRESS=${NET_SERVICE_ADDRESS}
|
||||
- API_URL=http://api:8080/api/
|
||||
|
@ -165,6 +164,8 @@ services:
|
|||
- p2pool-observer
|
||||
command: >-
|
||||
/usr/bin/web
|
||||
-host ${MONEROD_HOST}
|
||||
-rpc-port ${MONEROD_RPC_PORT}
|
||||
daemon:
|
||||
build:
|
||||
context: ./
|
||||
|
|
Loading…
Reference in a new issue