From 32909352896d9d2b244b32f1329668119b00e7fe Mon Sep 17 00:00:00 2001 From: Felix Schindler <107669806+ftschindler@users.noreply.github.com> Date: Thu, 24 Sep 2026 08:59:17 +0200 Subject: [PATCH] Persist the dev-server port across runs The port was rerolled on every serve, so the browser tab from the last run pointed at nothing. Pick it once into .serve-port and reuse it; delete the file to get a new one. --- .gitignore | 3 +++ Makefile | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 74b1a1e..58ff8ec 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,6 @@ site/ # Build artefact: the blog entrypoint mirrored where the blog plugin stats for # it; the source of truth is blog/index.md. See hooks/publish_siblings.py. docs/blog/ + +# Randomised dev-server port, picked once per clone +.serve-port diff --git a/Makefile b/Makefile index cf1af0e..528f9bc 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ .PHONY: help bootstrap site serve +PORT_FILE := .serve-port + ## Show available targets help: @grep -B1 '^[a-z]' $(MAKEFILE_LIST) | grep '^##' | sed 's/## / /' @@ -14,5 +16,10 @@ site: NO_MKDOCS_2_WARNING=true uv run mkdocs build --strict ## Start the live-reloading dev server -serve: - NO_MKDOCS_2_WARNING=true uv run mkdocs serve -a localhost:80$$(( RANDOM % 10 ))$$(( RANDOM % 10 )) +serve: $(PORT_FILE) + NO_MKDOCS_2_WARNING=true uv run mkdocs serve -a localhost:$$(cat $(PORT_FILE)) + +# Pick a random port once and reuse it; delete the file to get a new one +$(PORT_FILE): + awk 'BEGIN { srand(); print 8000 + int(rand() * 1000) }' > $@ + @echo "picked port $$(cat $@) (stored in $@)"