Skip to content

Commit

Permalink
make profiler work
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Nov 22, 2023
1 parent ffe7f1a commit 5124e3d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ build: vendor go.work snclient.ini server.crt server.key
( cd ./cmd/$$CMD && $(GOBUILD) -trimpath $(BUILD_FLAGS) -o ../../$$CMD ) ; \
done

builddebug: vendor go.work snclient.ini server.crt server.key
set -xe; for CMD in $(CMDS); do \
( cd ./cmd/$$CMD && $(GOBUILD) $(BUILD_FLAGS) -o ../../$$CMD ) ; \
done

# run build watch, ex. with tracing: make build-watch -- -vv -logfile stderr
build-watch: vendor tools
$(ENTR) "$(MAKE) && ./snclient $(filter-out $@,$(MAKECMDGOALS))"
Expand Down
3 changes: 3 additions & 0 deletions pkg/snclient/snclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"io"
"io/fs"
"net/http"
_ "net/http/pprof"
"os"
"os/exec"
"os/signal"
Expand Down Expand Up @@ -599,8 +600,10 @@ func (snc *Agent) checkFlags() {
ReadHeaderTimeout: DefaultSocketTimeout * time.Second,
WriteTimeout: DefaultSocketTimeout * time.Second,
IdleTimeout: DefaultSocketTimeout * time.Second,
Handler: http.DefaultServeMux,
}

log.Warnf("pprof profiler listening at http://%s/debug/pprof/ (make sure to use a binary without -trimpath, ex. from make builddebug)", snc.flags.ProfilePort)
err := server.ListenAndServe()
if err != nil {
log.Debugf("http.ListenAndServe finished with: %e", err)
Expand Down

0 comments on commit 5124e3d

Please sign in to comment.