updated http library to return error and response structs; updated how the GUI works to have a 'wait' UI; updated Makefile to ensure API is started before starting GUI
This commit is contained in:
@@ -16,9 +16,17 @@ RESOURCE_DIR := $(CURDIR)/resources/dev
|
||||
GUI_ENV_FILE ?= $(RESOURCE_DIR)/gui.env.example
|
||||
API_ENV_FILE ?= $(RESOURCE_DIR)/api.env.example
|
||||
API_DESI_DATA ?= $(RESOURCE_DIR)/desi_subset.json
|
||||
# The API binds here for local dev (see api/src/config.rs); `make run` passes
|
||||
# it through and waits for $(API_HEALTH_URL) to respond before launching the
|
||||
# GUI, so the renderer never races the API on startup. A bind host of
|
||||
# 0.0.0.0 is probed via 127.0.0.1. Adjust API_WAIT_TIMEOUT (seconds) if the
|
||||
# API takes longer than 60s to become healthy on a given machine.
|
||||
API_BIND_ADDR ?= 127.0.0.1:8080
|
||||
API_HEALTH_URL := http://$(subst 0.0.0.0,127.0.0.1,$(API_BIND_ADDR))/health
|
||||
API_WAIT_TIMEOUT ?= 60
|
||||
|
||||
.PHONY: help setup run run-web build build-debug build-web test clean fmt \
|
||||
renovate-validate
|
||||
api-wait renovate-validate
|
||||
|
||||
help: ## List available targets
|
||||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
|
||||
@@ -39,9 +47,10 @@ setup: ## Setup all sub-projects (submodules, gui deps, api deps, infra deps)
|
||||
|
||||
## ---- Renderer (Odin) -----------------------------------------------------
|
||||
|
||||
run: ## Run the native app (gui/)
|
||||
@API_ENV_FILE="$(API_ENV_FILE)" API_DESI_DATA="$(API_DESI_DATA)" $(MAKE) -C $(API) run & api_pid=$$!; \
|
||||
run: ## Run the native app (gui/); waits for the API to be healthy first
|
||||
@API_ENV_FILE="$(API_ENV_FILE)" API_DESI_DATA="$(API_DESI_DATA)" API_BIND_ADDR="$(API_BIND_ADDR)" $(MAKE) -C $(API) run & api_pid=$$!; \
|
||||
trap 'kill $$api_pid 2>/dev/null' INT TERM EXIT; \
|
||||
$(MAKE) api-wait || { kill $$api_pid 2>/dev/null; exit 1; }; \
|
||||
GUI_ENV_FILE="$(GUI_ENV_FILE)" $(MAKE) -C $(GUI) run; \
|
||||
kill $$api_pid 2>/dev/null
|
||||
|
||||
@@ -56,12 +65,28 @@ build-debug: ## Debug build (gui/ + api/)
|
||||
build-web: ## WebAssembly build -> build/web (gui/, needs emscripten)
|
||||
@$(MAKE) -C $(GUI) build-web
|
||||
|
||||
run-web: ## Start WASM build + API server for web dev
|
||||
@API_ENV_FILE="$(API_ENV_FILE)" API_DESI_DATA="$(API_DESI_DATA)" $(MAKE) -C $(API) run & api_pid=$$!; \
|
||||
run-web: ## Start WASM build + API server for web dev (waits for API health)
|
||||
@API_ENV_FILE="$(API_ENV_FILE)" API_DESI_DATA="$(API_DESI_DATA)" API_BIND_ADDR="$(API_BIND_ADDR)" $(MAKE) -C $(API) run & api_pid=$$!; \
|
||||
trap 'kill $$api_pid 2>/dev/null' INT TERM EXIT; \
|
||||
$(MAKE) api-wait || { kill $$api_pid 2>/dev/null; exit 1; }; \
|
||||
GUI_ENV_FILE="$(GUI_ENV_FILE)" $(MAKE) -C $(GUI) build-web; \
|
||||
kill $$api_pid 2>/dev/null
|
||||
|
||||
## ---- Dev helpers ----------------------------------------------------------
|
||||
|
||||
api-wait: ## Poll the API health endpoint until it responds (or times out)
|
||||
@echo "Waiting for API at $(API_HEALTH_URL) ..."; \
|
||||
elapsed=0; \
|
||||
while ! curl -sf "$(API_HEALTH_URL)" >/dev/null 2>&1; do \
|
||||
elapsed=$$((elapsed + 1)); \
|
||||
if [ "$${elapsed}" -ge "$(API_WAIT_TIMEOUT)" ]; then \
|
||||
echo "Error: API at $(API_HEALTH_URL) not healthy after $(API_WAIT_TIMEOUT)s" >&2; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
sleep 1; \
|
||||
done; \
|
||||
echo "API is up."
|
||||
|
||||
## ---- Aggregates ----------------------------------------------------------
|
||||
|
||||
test: ## Test all projects (odin + cargo + go)
|
||||
|
||||
Reference in New Issue
Block a user