Use common.SignalHandlerLoop from weave, and document debug options.

This commit is contained in:
Tom Wilkie
2015-12-04 10:01:00 +00:00
parent a9b868d310
commit 99d72cbc2b
3 changed files with 29 additions and 18 deletions

View File

@@ -210,3 +210,28 @@ Then, run the local build via
```
./scope launch
```
## <a name="developing"></a>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
```

View File

@@ -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()
}

View File

@@ -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()
}