From dc5131f2c9af703ac0a0b80f7ca1881fd88ba1b3 Mon Sep 17 00:00:00 2001 From: fffw Date: Thu, 17 Dec 2015 21:18:34 +0800 Subject: [PATCH] add pprofaddr option resolves #3291 --- src/github.com/getlantern/flashlight/flashlight.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/github.com/getlantern/flashlight/flashlight.go b/src/github.com/getlantern/flashlight/flashlight.go index 45817298eb..764c9971e6 100644 --- a/src/github.com/getlantern/flashlight/flashlight.go +++ b/src/github.com/getlantern/flashlight/flashlight.go @@ -7,6 +7,7 @@ import ( "math/rand" "net" "net/http" + _ "net/http/pprof" "os" "os/signal" "runtime" @@ -51,6 +52,7 @@ var ( headless = flag.Bool("headless", false, "if true, lantern will run with no ui") startup = flag.Bool("startup", false, "if true, Lantern was automatically run on system startup") clearProxySettings = flag.Bool("clear-proxy-settings", false, "if true, Lantern removes proxy settings from the system.") + pprofAddr = flag.String("pprofaddr", "", "pprof address to listen on, not activate pprof if empty") showui = true @@ -128,6 +130,15 @@ func main() { parseFlags() + if *pprofAddr != "" { + go func() { + log.Debugf("Starting pprof page at http://%s/debug/pprof", *pprofAddr) + if err := http.ListenAndServe(*pprofAddr, nil); err != nil { + log.Error(err) + } + }() + } + showui = !*headless if showui {