Add pprof

This commit is contained in:
Jon Staab
2026-04-15 12:51:13 -07:00
parent dc8c16527b
commit b067b8b2b6
3 changed files with 14 additions and 0 deletions
+1
View File
@@ -16,6 +16,7 @@ Zooid supports a few environment variables, which configure shared resources lik
- `DATA` - where to store databse files. Defaults to `./data`.
- `API_HOST` - the hostname on which to expose the management API. If not set, the API is disabled.
- `API_WHITELIST` - a comma-separated list of nostr hex pubkeys authorized to use the management API. Required when `API_HOST` is set.
- `PPROF_ADDR` - an http host to serve pprof stats on.
## Configuration
+13
View File
@@ -5,6 +5,7 @@ import (
"fmt"
"log"
"net/http"
_ "net/http/pprof"
"os"
"os/signal"
"syscall"
@@ -22,6 +23,18 @@ func main() {
apiHost := zooid.Env("API_HOST")
apiWhitelist := zooid.Env("API_WHITELIST")
configDir := zooid.Env("CONFIG")
pprofAddr := zooid.Env("PPROF_ADDR")
// pprof server — only starts when PPROF_ADDR is set. Bind to
// 127.0.0.1:6060 (or similar) and tunnel via SSH; never expose publicly.
if pprofAddr != "" {
go func() {
log.Printf("pprof listening on %s\n", pprofAddr)
if err := http.ListenAndServe(pprofAddr, nil); err != nil {
log.Printf("pprof server error: %v\n", err)
}
}()
}
// Create the main handler
mainHandler := http.HandlerFunc(
BIN
View File
Binary file not shown.