From e342fdc3e634e75e33c465afddf5e85dab04d760 Mon Sep 17 00:00:00 2001 From: Matthias Loibl Date: Mon, 30 Jan 2017 23:38:27 +0100 Subject: [PATCH 1/2] Add ENABLE_PPROF to app.ini and start pprof if true on localhost:6060 --- cmd/web.go | 7 +++++++ modules/setting/setting.go | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cmd/web.go b/cmd/web.go index 2e5ae8cd58833..b704340f85597 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -9,6 +9,7 @@ import ( "net" "net/http" "net/http/fcgi" + _ "net/http/pprof" "os" "path" "strings" @@ -645,6 +646,12 @@ func runWeb(ctx *cli.Context) error { log.Info("LFS server enabled") } + if setting.EnablePprof { + go func() { + log.Info("%v", http.ListenAndServe("localhost:6060", nil)) + }() + } + var err error switch setting.Protocol { case setting.HTTP: diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 0586bce94b6c8..7737a6be37bc6 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -30,7 +30,7 @@ import ( _ "github.com/go-macaron/cache/redis" "github.com/go-macaron/session" _ "github.com/go-macaron/session/redis" // redis plugin for store session - "gopkg.in/ini.v1" + ini "gopkg.in/ini.v1" "strk.kbt.io/projects/go/libravatar" ) @@ -79,6 +79,7 @@ var ( EnableGzip bool LandingPageURL LandingPage UnixSocketPermission uint32 + EnablePprof bool SSH = struct { Disabled bool `ini:"DISABLE_SSH"` @@ -591,6 +592,7 @@ please consider changing to GITEA_CUSTOM`) StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(workDir) AppDataPath = sec.Key("APP_DATA_PATH").MustString("data") EnableGzip = sec.Key("ENABLE_GZIP").MustBool() + EnablePprof = sec.Key("ENABLE_PPROF").MustBool(false) switch sec.Key("LANDING_PAGE").MustString("home") { case "explore": From 69f4c1ed04a1d8e3118bbb06feceeee0d15cc250 Mon Sep 17 00:00:00 2001 From: Matthias Loibl Date: Mon, 30 Jan 2017 23:55:30 +0100 Subject: [PATCH 2/2] Add comment for golint to blank pprof import --- cmd/web.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/web.go b/cmd/web.go index b704340f85597..bb086accc7c1d 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -9,7 +9,7 @@ import ( "net" "net/http" "net/http/fcgi" - _ "net/http/pprof" + _ "net/http/pprof" // Used for debugging if enabled and a web server is running "os" "path" "strings"