Skip to content

Commit ad18b17

Browse files
committed
loopd: add profiler to the Loop daemon
1 parent 2d26575 commit ad18b17

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

loopd/daemon.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"net"
99
"net/http"
10+
_ "net/http/pprof" //nolint:gosec
1011
"strings"
1112
"sync"
1213
"sync/atomic"
@@ -133,6 +134,16 @@ func (d *Daemon) Start() error {
133134
return errOnlyStartOnce
134135
}
135136

137+
go func() {
138+
http.Handle("/", http.RedirectHandler(
139+
"/debug/pprof", http.StatusSeeOther,
140+
))
141+
142+
listenAddr := fmt.Sprintf(":%d", 4321)
143+
infof("Starting profile server at %s", listenAddr)
144+
fmt.Println(http.ListenAndServe(listenAddr, nil)) // nolint: gosec
145+
}()
146+
136147
network := lndclient.Network(d.cfg.Network)
137148

138149
var err error

0 commit comments

Comments
 (0)