diff --git a/Justfile b/Justfile
index 0bf38a3..231df7f 100644
--- a/Justfile
+++ b/Justfile
@@ -1,13 +1,13 @@
CGO_FLAGS := '-extldflags "-static" -linkmode external'
TAGS := 'sqlite sqlite_unlock_notify netgo'
-dev:
+dev *FLAGS:
#!/usr/bin/env bash
set -euxo pipefail
set -a # automatically export all variables
source .env-dev
set +a
- go run -tags '{{TAGS}}' .
+ go run -tags '{{TAGS}}' . {{FLAGS}}
build:
CGO_ENABLED=1 go build -tags '{{TAGS}}' -ldflags '-s -w {{CGO_FLAGS}}' -v -o build/codeberg-pages-server ./
diff --git a/README.md b/README.md
index c23d86a..a1d6424 100644
--- a/README.md
+++ b/README.md
@@ -124,3 +124,18 @@ now these pages should work:
-
-
-
+
+### Profiling
+
+> This section is just a collection of commands for quick reference. If you want to learn more about profiling read [this](https://go.dev/doc/diagnostics) article or google `golang profiling`.
+
+First enable profiling by supplying the cli arg `--enable-profiling` or using the environment variable `EENABLE_PROFILING`.
+
+Get cpu and mem stats:
+
+```bash
+go tool pprof -raw -output=cpu.txt 'http://localhost:9999/debug/pprof/profile?seconds=60' &
+curl -so mem.txt 'http://localhost:9999/debug/pprof/heap?seconds=60'
+```
+
+More endpoints are documented here:
diff --git a/server/profiling.go b/server/profiling.go
index 7d1971f..7d20926 100644
--- a/server/profiling.go
+++ b/server/profiling.go
@@ -1,9 +1,10 @@
package server
import (
- "log"
"net/http"
_ "net/http/pprof"
+
+ "github.com/rs/zerolog/log"
)
func StartProfilingServer(listeningAddress string) {
@@ -12,7 +13,9 @@ func StartProfilingServer(listeningAddress string) {
Handler: http.DefaultServeMux,
}
+ log.Info().Msgf("Starting debug server on %s", listeningAddress)
+
go func() {
- log.Fatal(server.ListenAndServe())
+ log.Fatal().Err(server.ListenAndServe()).Msg("Failed to start debug server")
}()
}