#!/usr/bin/env bash set -euo pipefail REPO_DIR="/home/jan/Documents/RFP/Infinity_Vis_Rust" PORT="${1:-9011}" BASE_URL="http://127.0.0.1:${PORT}" RUNTIME_STATE="/tmp/infinity_vis_runtime_codex_browser_${PORT}.json" cd "$REPO_DIR" . "$HOME/.cargo/env" cargo run -q -p infinity_host_api -- \ --config config/project.example.toml \ --bind "127.0.0.1:${PORT}" \ --runtime-state "$RUNTIME_STATE" & SERVER_PID=$! cleanup() { if kill -0 "$SERVER_PID" >/dev/null 2>&1; then kill "$SERVER_PID" >/dev/null 2>&1 || true wait "$SERVER_PID" >/dev/null 2>&1 || true fi } trap cleanup EXIT INT TERM for _attempt in $(seq 1 40); do if curl -fsS "${BASE_URL}/api/v1/state" >/dev/null 2>&1; then break fi sleep 0.25 done echo "Smoke-checking ${BASE_URL}/" curl -fsS "${BASE_URL}/" >/tmp/infinity_vis_creative_${PORT}.html >/dev/null echo "Smoke-checking ${BASE_URL}/technical" curl -fsS "${BASE_URL}/technical" >/tmp/infinity_vis_technical_${PORT}.html >/dev/null echo "Smoke-checking ${BASE_URL}/technical.js" curl -fsS "${BASE_URL}/technical.js" >/tmp/infinity_vis_technical_${PORT}.js >/dev/null echo "Creative Surface and Technical Surface were served successfully on ${BASE_URL}" echo "Saved smoke artifacts to /tmp/infinity_vis_creative_${PORT}.html and /tmp/infinity_vis_technical_${PORT}.html" if command -v xdg-open >/dev/null 2>&1; then echo "Optional manual open:" echo " xdg-open ${BASE_URL}/" echo " xdg-open ${BASE_URL}/technical" fi