make lan: a fresh distd always serving the .lan store on the LAN

Rebuilds, frees the port (stale servers from earlier sessions squat on
it), and restarts detached on 0.0.0.0:8787; the .lan/ store and its log
are long-lived and gitignored.
This commit is contained in:
agra
2026-06-12 19:57:03 +03:00
parent eef3d5c437
commit 963a21596a
2 changed files with 18 additions and 1 deletions

3
.gitignore vendored
View File

@@ -9,5 +9,8 @@ build/
# scratch store roots / fixtures created by tests (never /tmp) # scratch store roots / fixtures created by tests (never /tmp)
.sx-tmp/ .sx-tmp/
# the long-running LAN demo store served by `make lan`
.lan/
# sx compiler caches (object cache for #import c units etc.) # sx compiler caches (object cache for #import c units etc.)
.sx-cache/ .sx-cache/

View File

@@ -20,7 +20,7 @@ BUILD_DIR := build
SMOKE := tests/smoke.sx SMOKE := tests/smoke.sx
DIST := src/dist.sx DIST := src/dist.sx
.PHONY: build test publish-example clean .PHONY: build test publish-example lan clean
# Compile the product sources (and the smoke program) without running. # Compile the product sources (and the smoke program) without running.
build: build:
@@ -42,5 +42,19 @@ publish-example: build
@rm -rf .sx-tmp/publish-example @rm -rf .sx-tmp/publish-example
./$(BUILD_DIR)/dist ci publish --manifest examples/dist.json --local-store .sx-tmp/publish-example --json ./$(BUILD_DIR)/dist ci publish --manifest examples/dist.json --local-store .sx-tmp/publish-example --json
# Serve the persistent .lan/ store on 0.0.0.0:$(LAN_PORT) for LAN access.
# Rebuilds first and REPLACES any running instance, so the served binary
# is always the current tree. Detached via nohup; log lives with the
# store's other state (one data dir, like the /data volume in PLAN.md).
LAN_PORT ?= 8787
LAN_STORE ?= .lan
lan: build
@pkill -f "dist server run --local-store $(LAN_STORE)" 2>/dev/null || true
@lsof -tiTCP:$(LAN_PORT) -sTCP:LISTEN | xargs kill 2>/dev/null || true; sleep 0.3
@mkdir -p $(LAN_STORE)
@sh -c 'nohup ./$(BUILD_DIR)/dist server run --local-store $(LAN_STORE) --port $(LAN_PORT) >> $(LAN_STORE)/distd.log 2>&1 & echo "distd pid $$!"'
@echo "admin: http://$$(ipconfig getifaddr en0 2>/dev/null || echo localhost):$(LAN_PORT)/admin"
clean: clean:
@rm -rf $(BUILD_DIR) .sx-cache @rm -rf $(BUILD_DIR) .sx-cache