diff --git a/server.conf.in b/server.conf.in index ec3def02..07bf5f80 100644 --- a/server.conf.in +++ b/server.conf.in @@ -8,6 +8,7 @@ listen = 127.0.0.1:8080 #basePath = /some/sub/path/ # Set this when running behind a web server under a sub path. #maxfd = 32768 # Try to set max open files limit on start (works only when run as root). #stats = true # Provide stats API at /api/v1/stats (do not enable this in production or unprotected!). +#pprofListen = 127.0.0.1:6060 # See http://golang.org/pkg/net/http/pprof/ for details [app] #title = Spreed Speak Freely diff --git a/src/app/spreed-speakfreely-server/main.go b/src/app/spreed-speakfreely-server/main.go index a30cac59..9265af23 100644 --- a/src/app/spreed-speakfreely-server/main.go +++ b/src/app/spreed-speakfreely-server/main.go @@ -31,6 +31,7 @@ import ( "html/template" "log" "net/http" + _ "net/http/pprof" "os" "path" goruntime "runtime" @@ -153,6 +154,14 @@ func runner(runtime phoenix.Runtime) error { statsEnabled = false } + pprofListen, err := runtime.GetString("http", "pprofListen") + if err == nil && pprofListen != "" { + log.Printf("Starting pprof HTTP server on %s", pprofListen) + go func() { + log.Println(http.ListenAndServe(pprofListen, nil)) + }() + } + sessionSecret, err := runtime.GetString("app", "sessionSecret") if err != nil { return fmt.Errorf("No sessionSecret in config file.")