Add --profile to enable live profiling
This commit is contained in:
parent
57802d8daf
commit
6558986cc5
2 changed files with 15 additions and 0 deletions
14
cmd.go
14
cmd.go
|
@ -26,6 +26,9 @@ import (
|
|||
"github.com/conformal/btcwire"
|
||||
"github.com/conformal/btcws"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
@ -295,6 +298,17 @@ func main() {
|
|||
loggers = setLogLevel(cfg.DebugLevel)
|
||||
}
|
||||
|
||||
if cfg.Profile != "" {
|
||||
go func() {
|
||||
listenAddr := net.JoinHostPort("", cfg.Profile)
|
||||
log.Infof("Profile server listening on %s", listenAddr)
|
||||
profileRedirect := http.RedirectHandler("/debug/pprof",
|
||||
http.StatusSeeOther)
|
||||
http.Handle("/", profileRedirect)
|
||||
log.Errorf("%v", http.ListenAndServe(listenAddr, nil))
|
||||
}()
|
||||
}
|
||||
|
||||
// Open default account
|
||||
a, err := OpenAccount(cfg, "")
|
||||
switch err {
|
||||
|
|
|
@ -56,6 +56,7 @@ type config struct {
|
|||
Proxy string `long:"proxy" description:"Connect via SOCKS5 proxy (eg. 127.0.0.1:9050)"`
|
||||
ProxyUser string `long:"proxyuser" description:"Username for proxy server"`
|
||||
ProxyPass string `long:"proxypass" default-mask:"-" description:"Password for proxy server"`
|
||||
Profile string `long:"profile" description:"Enable HTTP profiling on given port -- NOTE port must be between 1024 and 65536"`
|
||||
}
|
||||
|
||||
// cleanAndExpandPath expands environement variables and leading ~ in the
|
||||
|
|
Loading…
Reference in a new issue