diff --git a/.gitignore b/.gitignore index 2bd24e4..b4e2263 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,8 @@ build/ # scratch store roots / fixtures created by tests (never /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-cache/ diff --git a/Makefile b/Makefile index d18cd43..57e58d6 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ BUILD_DIR := build SMOKE := tests/smoke.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. build: @@ -42,5 +42,19 @@ publish-example: build @rm -rf .sx-tmp/publish-example ./$(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: @rm -rf $(BUILD_DIR) .sx-cache