aboutsummaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2026-08-23 15:38:08 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2026-08-23 15:38:08 +0200
commit2d8503cafb9f63ca4cb63f041281987f9a63f16a (patch)
treec90cb273473f265b1d0beb1004d9b0e4dfbeee03 /cli
parent1125e0b7086dd2b71e0558aaf641c23dea02f200 (diff)
Add on-demand pprof profiling grouped by route
Expose pprof at /debug/pprof via -pprof flag, tag each handler with runtime/pprof route label, add handleRoute helper to avoid repeating patterns, and document UI workflow in README.
Diffstat (limited to 'cli')
-rw-r--r--cli/cli.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/cli/cli.go b/cli/cli.go
index 68a86a6..bd54b35 100644
--- a/cli/cli.go
+++ b/cli/cli.go
@@ -21,10 +21,11 @@ import (
)
var (
- fetchOSM = flag.Bool("fetch-osm", false, "download the France OSM PBF (resumable) into france-latest.osm.pbf")
- extractOSM = flag.String("extract-osm", "", "extract mountain passes from an OSM PBF file into the database")
- backfill = flag.Bool("backfill", false, "recompute all stored ride values")
- backtest = flag.Bool("backtest", false, "run data benchmarks comparing computed values against stored reference values")
+ fetchOSM = flag.Bool("fetch-osm", false, "download the France OSM PBF (resumable) into france-latest.osm.pbf")
+ extractOSM = flag.String("extract-osm", "", "extract mountain passes from an OSM PBF file into the database")
+ backfill = flag.Bool("backfill", false, "recompute all stored ride values")
+ backtest = flag.Bool("backtest", false, "run data benchmarks comparing computed values against stored reference values")
+ enablePprof = flag.Bool("pprof", false, "expose pprof endpoints at /debug/pprof")
)
const (
@@ -52,7 +53,10 @@ func Run(db *sql.DB, configPath string, appConfig config.Config) {
}
func runServer(db *sql.DB, configPath string, appConfig config.Config) {
- server := web.NewServer(db, configPath)
+ server := web.NewServer(db, configPath).WithPprof(*enablePprof)
+ if *enablePprof {
+ slog.Info("pprof enabled", "endpoint", appConfig.Server.PublicURL+"/debug/pprof/")
+ }
slog.Info("Starting web server", "address", appConfig.Server.PublicURL)
kcore.Expect(server.ListenAndServe(appConfig.Server.Address), "web server stopped")
}