Bläddra i källkod

Add ENABLE_PPROF to app.ini and start pprof if true on localhost:6060 (#801)

* Add ENABLE_PPROF to app.ini and start pprof if true on localhost:6060

* Add comment for golint to blank pprof import
tags/v1.1.0
Matthias Loibl 7 år sedan
förälder
incheckning
17c5e12e6e
2 ändrade filer med 10 tillägg och 1 borttagningar
  1. 7
    0
      cmd/web.go
  2. 3
    1
      modules/setting/setting.go

+ 7
- 0
cmd/web.go Visa fil

@@ -9,6 +9,7 @@ import (
"net"
"net/http"
"net/http/fcgi"
_ "net/http/pprof" // Used for debugging if enabled and a web server is running
"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:

+ 3
- 1
modules/setting/setting.go Visa fil

@@ -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":

Laddar…
Avbryt
Spara