mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-02 09:40:34 +00:00
Use common.SignalHandlerLoop from weave, and document debug options.
This commit is contained in:
25
README.md
25
README.md
@@ -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
|
||||
```
|
||||
|
||||
11
app/main.go
11
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()
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user