Pull request: imp-pprof

Merge in DNS/adguard-home from imp-pprof to master

Squashed commit of the following:

commit cd6c2ec15342ef55957ab65e1599733c2ee57b7b
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Mon Nov 7 19:45:12 2022 +0300

    home: imp pprof handling, field alignment
This commit is contained in:
Ainar Garipov 2022-11-08 11:36:42 +03:00
parent 464fbf0b54
commit 8fdbcc005c
1 changed files with 16 additions and 2 deletions

View File

@ -76,9 +76,7 @@ type homeContext struct {
configFilename string // Config filename (can be overridden via the command line arguments)
workDir string // Location of our directory, used to protect against CWD being somewhere else
firstRun bool // if set to true, don't run any services except HTTP web interface, and serve only first-run html
pidFileName string // PID file name. Empty if no PID file was created.
disableUpdate bool // If set, don't check for updates
controlLock sync.Mutex
tlsRoots *x509.CertPool // list of root CAs for TLSv1.2
transport *http.Transport
@ -88,6 +86,13 @@ type homeContext struct {
// tlsCipherIDs are the ID of the cipher suites that AdGuard Home must use.
tlsCipherIDs []uint16
// disableUpdate, if true, tells AdGuard Home to not check for updates.
disableUpdate bool
// firstRun, if true, tells AdGuard Home to only start the web interface
// service, and only serve the first-run APIs.
firstRun bool
// runningAsService flag is set to true when options are passed from the service runner
runningAsService bool
}
@ -462,6 +467,15 @@ func run(opts options, clientBuildFS fs.FS) {
mux.HandleFunc("/debug/pprof/profile", pprof.Profile)
mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol)
mux.HandleFunc("/debug/pprof/trace", pprof.Trace)
// See profileSupportsDelta in src/net/http/pprof/pprof.go.
mux.Handle("/debug/pprof/allocs", pprof.Handler("allocs"))
mux.Handle("/debug/pprof/block", pprof.Handler("block"))
mux.Handle("/debug/pprof/goroutine", pprof.Handler("goroutine"))
mux.Handle("/debug/pprof/heap", pprof.Handler("heap"))
mux.Handle("/debug/pprof/mutex", pprof.Handler("mutex"))
mux.Handle("/debug/pprof/threadcreate", pprof.Handler("threadcreate"))
go func() {
log.Info("pprof: listening on localhost:6060")
lerr := http.ListenAndServe("localhost:6060", mux)