From c8301c5947b9e16a95a108852db174fdeffc245b Mon Sep 17 00:00:00 2001 From: giles Date: Sat, 28 Mar 2026 17:15:51 +0000 Subject: [PATCH] dev-sx-native.sh: run sx-docs with OCaml HTTP server, no Docker/Python MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Single command to start the native OCaml HTTP server for sx-docs. No Docker, no Python, no Quart — just the OCaml binary + Caddy. ./dev-sx-native.sh # port 8013 ./dev-sx-native.sh 8014 # custom port ./dev-sx-native.sh --build # rebuild first Co-Authored-By: Claude Opus 4.6 (1M context) --- dev-sx-native.sh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 dev-sx-native.sh diff --git a/dev-sx-native.sh b/dev-sx-native.sh new file mode 100755 index 00000000..bb47dc38 --- /dev/null +++ b/dev-sx-native.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Dev mode for sx_docs using the native OCaml HTTP server. +# No Docker, no Python, no Quart — just the OCaml binary. +# Caddy still handles TLS and static files on externalnet. +# +# Usage: +# ./dev-sx-native.sh # Start on port 8013 +# ./dev-sx-native.sh 8014 # Start on custom port +# ./dev-sx-native.sh --build # Rebuild OCaml binary first + +PORT="${1:-8013}" +BUILD=false + +if [[ "${1:-}" == "--build" ]]; then + BUILD=true + PORT="${2:-8013}" +fi + +# Build if requested or binary doesn't exist +BIN="hosts/ocaml/_build/default/bin/sx_server.exe" +if [[ "$BUILD" == true ]] || [[ ! -f "$BIN" ]]; then + echo "[dev-sx-native] Building OCaml binary..." + cd hosts/ocaml && eval "$(opam env)" && dune build bin/sx_server.exe && cd ../.. + echo "[dev-sx-native] Build complete" +fi + +# Set project dir so the server finds spec/, lib/, web/, sx/sx/ +export SX_PROJECT_DIR="$(pwd)" + +echo "[dev-sx-native] Starting OCaml HTTP server on port $PORT" +echo "[dev-sx-native] project=$SX_PROJECT_DIR" +echo "[dev-sx-native] binary=$BIN" +echo "" + +exec "$BIN" --http "$PORT"