Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Feb 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmd/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion modules/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -79,6 +79,7 @@ var (
EnableGzip bool
LandingPageURL LandingPage
UnixSocketPermission uint32
EnablePprof bool

SSH = struct {
Disabled bool `ini:"DISABLE_SSH"`
Expand Down Expand Up @@ -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":
Expand Down