diff --git a/cmd/strelaysrv/main.go b/cmd/strelaysrv/main.go index 80738cc9..f1daf169 100644 --- a/cmd/strelaysrv/main.go +++ b/cmd/strelaysrv/main.go @@ -81,6 +81,8 @@ var ( natLease int natRenewal int natTimeout int + + pprofEnabled bool ) func main() { @@ -105,6 +107,7 @@ func main() { flag.IntVar(&natLease, "nat-lease", 60, "NAT lease length in minutes") flag.IntVar(&natRenewal, "nat-renewal", 30, "NAT renewal frequency in minutes") flag.IntVar(&natTimeout, "nat-timeout", 10, "NAT discovery timeout in seconds") + flag.BoolVar(&pprofEnabled, "pprof", false, "Enable the built in profiling on the status server") flag.Parse() if extAddress == "" { diff --git a/cmd/strelaysrv/status.go b/cmd/strelaysrv/status.go index 573d6dfa..8d27e43e 100644 --- a/cmd/strelaysrv/status.go +++ b/cmd/strelaysrv/status.go @@ -6,6 +6,7 @@ import ( "encoding/json" "log" "net/http" + "net/http/pprof" "runtime" "sync/atomic" "time" @@ -18,6 +19,9 @@ func statusService(addr string) { handler := http.NewServeMux() handler.HandleFunc("/status", getStatus) + if pprofEnabled { + handler.HandleFunc("/debug/pprof/", pprof.Index) + } srv := http.Server{ Addr: addr,