mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-24 07:28:27 +00:00
cmd/strelaysrv: Add profiling support, default disabled
This commit is contained in:
parent
5883eb9a25
commit
7aaa92ac47
@ -81,6 +81,8 @@ var (
|
|||||||
natLease int
|
natLease int
|
||||||
natRenewal int
|
natRenewal int
|
||||||
natTimeout int
|
natTimeout int
|
||||||
|
|
||||||
|
pprofEnabled bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -105,6 +107,7 @@ func main() {
|
|||||||
flag.IntVar(&natLease, "nat-lease", 60, "NAT lease length in minutes")
|
flag.IntVar(&natLease, "nat-lease", 60, "NAT lease length in minutes")
|
||||||
flag.IntVar(&natRenewal, "nat-renewal", 30, "NAT renewal frequency 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.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()
|
flag.Parse()
|
||||||
|
|
||||||
if extAddress == "" {
|
if extAddress == "" {
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/http/pprof"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
@ -18,6 +19,9 @@ func statusService(addr string) {
|
|||||||
|
|
||||||
handler := http.NewServeMux()
|
handler := http.NewServeMux()
|
||||||
handler.HandleFunc("/status", getStatus)
|
handler.HandleFunc("/status", getStatus)
|
||||||
|
if pprofEnabled {
|
||||||
|
handler.HandleFunc("/debug/pprof/", pprof.Index)
|
||||||
|
}
|
||||||
|
|
||||||
srv := http.Server{
|
srv := http.Server{
|
||||||
Addr: addr,
|
Addr: addr,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user