From 99d72cbc2b7d69d620a42ff158ef59de55cb3fdb Mon Sep 17 00:00:00 2001 From: Tom Wilkie Date: Fri, 4 Dec 2015 10:01:00 +0000 Subject: [PATCH] Use common.SignalHandlerLoop from weave, and document debug options. --- README.md | 25 +++++++++++++++++++++++++ app/main.go | 11 ++--------- prog/probe/main.go | 11 ++--------- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index d252eaf3c..b5f262142 100644 --- a/README.md +++ b/README.md @@ -210,3 +210,28 @@ Then, run the local build via ``` ./scope launch ``` + +## Debugging + +Scope has a collection of built in debugging tools to aid Scope delevopers. + +- To have the app or probe dump their goroutine stacks, run: +``` +pkill -SIGQUIT scope-(app|probe) +docker logs weavescope +``` + +- The probe is instrumented with various counters and timers. To have it dump + those values, run: +``` +pkill -SIGUSR1 scope-probe +docker logs weavescope +``` + +- The app and probe both include golang's pprof integration for gathering CPU + and memory profiles. To use these with the probe, you must launch Scope with + the following arguments `scope launch --probe.http.listen :4041`. You can + then collect profiles in the usual way: +``` +go tool pprof http://localhost:(4040|4041)/debug/pprof/profile +``` diff --git a/app/main.go b/app/main.go index 64dd102d8..232030011 100644 --- a/app/main.go +++ b/app/main.go @@ -7,14 +7,12 @@ import ( "math/rand" "net/http" _ "net/http/pprof" - "os" - "os/signal" "strconv" "strings" - "syscall" "time" "github.com/gorilla/mux" + "github.com/weaveworks/weave/common" "github.com/weaveworks/scope/xfer" ) @@ -71,11 +69,6 @@ func main() { log.Printf("listening on %s", *listen) log.Print(http.ListenAndServe(*listen, nil)) }() - log.Printf("%s", <-interrupt()) -} -func interrupt() chan os.Signal { - c := make(chan os.Signal) - signal.Notify(c, syscall.SIGINT, syscall.SIGTERM) - return c + common.SignalHandlerLoop() } diff --git a/prog/probe/main.go b/prog/probe/main.go index 03f28cdb3..33d4c6636 100644 --- a/prog/probe/main.go +++ b/prog/probe/main.go @@ -9,13 +9,12 @@ import ( "net/http" _ "net/http/pprof" "os" - "os/signal" "strconv" "strings" - "syscall" "time" "github.com/armon/go-metrics" + "github.com/weaveworks/weave/common" "github.com/weaveworks/scope/probe" "github.com/weaveworks/scope/probe/controls" @@ -176,11 +175,5 @@ func main() { p.Start() defer p.Stop() - log.Printf("%s", <-interrupt()) -} - -func interrupt() <-chan os.Signal { - c := make(chan os.Signal) - signal.Notify(c, syscall.SIGINT, syscall.SIGTERM) - return c + common.SignalHandlerLoop() }