Skip to content

Commit e617f34

Browse files
authored
feat: enable pprof endpoint for orchestrator (#460)
1 parent 165c9f5 commit e617f34

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Taskfile.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,20 @@ tasks:
155155
- git tag -a "{{.CLI_ARGS}}" -m "Release {{.CLI_ARGS}}"
156156
- git push origin "{{.CLI_ARGS}}"
157157

158+
arduino-app-cli:start:
159+
desc: "build and launch the arduino-app-cli in daemon mode"
160+
cmds:
161+
- task arduino-app-cli:build:local
162+
- ./build/arduino-app-cli daemon --port 6060
163+
164+
arduino-app-cli:pprof:
165+
desc: Open pprof UI
166+
cmds:
167+
- go tool pprof -http=:8080 {{ .URL }}/debug/pprof/{{ .TYPE }}
168+
vars:
169+
TYPE: '{{.TYPE | default "heap"}}' # goroutine, heap, mutex
170+
URL: '{{ .URL| default "http://localhost:6060" }}'
171+
158172
adbd:start:
159173
desc: interact with adbd
160174
cmds:

internal/api/api.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
"github.com/bcmi-labs/orchestrator/internal/update"
1313

1414
dockerClient "github.com/docker/docker/client"
15+
16+
_ "net/http/pprof" //nolint:gosec // pprof import is safe for profiling endpoints
1517
)
1618

1719
//go:embed docs
@@ -27,6 +29,7 @@ func NewHTTPRouter(
2729
bricksIndex *bricksindex.BricksIndex,
2830
) http.Handler {
2931
mux := http.NewServeMux()
32+
mux.Handle("GET /debug/", http.DefaultServeMux) // pprof endpoints
3033

3134
mux.Handle("GET /v1/version", handlers.HandlerVersion(version))
3235
mux.Handle("GET /v1/config", handlers.HandleConfig())

0 commit comments

Comments
 (0)