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:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -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/
|
||||
|
||||
16
Makefile
16
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
|
||||
|
||||
Reference in New Issue
Block a user