Skip to content

Commit 17c5e12

Browse files
metalmatzelunny
authored andcommitted
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
1 parent c73b7a6 commit 17c5e12

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

cmd/web.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"net"
1010
"net/http"
1111
"net/http/fcgi"
12+
_ "net/http/pprof" // Used for debugging if enabled and a web server is running
1213
"os"
1314
"path"
1415
"strings"
@@ -645,6 +646,12 @@ func runWeb(ctx *cli.Context) error {
645646
log.Info("LFS server enabled")
646647
}
647648

649+
if setting.EnablePprof {
650+
go func() {
651+
log.Info("%v", http.ListenAndServe("localhost:6060", nil))
652+
}()
653+
}
654+
648655
var err error
649656
switch setting.Protocol {
650657
case setting.HTTP:

modules/setting/setting.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
_ "github.com/go-macaron/cache/redis"
3131
"github.com/go-macaron/session"
3232
_ "github.com/go-macaron/session/redis" // redis plugin for store session
33-
"gopkg.in/ini.v1"
33+
ini "gopkg.in/ini.v1"
3434
"strk.kbt.io/projects/go/libravatar"
3535
)
3636

@@ -79,6 +79,7 @@ var (
7979
EnableGzip bool
8080
LandingPageURL LandingPage
8181
UnixSocketPermission uint32
82+
EnablePprof bool
8283

8384
SSH = struct {
8485
Disabled bool `ini:"DISABLE_SSH"`
@@ -591,6 +592,7 @@ please consider changing to GITEA_CUSTOM`)
591592
StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(workDir)
592593
AppDataPath = sec.Key("APP_DATA_PATH").MustString("data")
593594
EnableGzip = sec.Key("ENABLE_GZIP").MustBool()
595+
EnablePprof = sec.Key("ENABLE_PPROF").MustBool(false)
594596

595597
switch sec.Key("LANDING_PAGE").MustString("home") {
596598
case "explore":

0 commit comments

Comments
 (0)