diff options
| author | info@mode42.com <info@mode42.com> | 2026-08-07 18:25:13 +0000 |
|---|---|---|
| committer | info@mode42.com <info@mode42.com> | 2026-08-07 18:25:13 +0000 |
| commit | 04d965d67a7264a1c7c211494aebda1953df7603 (patch) | |
| tree | 0ebd700a6e219f84a26a656f4bee8778bc75da7b /stacks/web/scripts | |
Initial push
Diffstat (limited to 'stacks/web/scripts')
| -rw-r--r-- | stacks/web/scripts/dev-router.php | 21 | ||||
| -rwxr-xr-x | stacks/web/scripts/dev-server.sh | 32 |
2 files changed, 53 insertions, 0 deletions
diff --git a/stacks/web/scripts/dev-router.php b/stacks/web/scripts/dev-router.php new file mode 100644 index 0000000..fd44559 --- /dev/null +++ b/stacks/web/scripts/dev-router.php @@ -0,0 +1,21 @@ +<?php +/** + * PHP built-in server router for local dev (direct loopback WebSocket URL). + */ +$uri = parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?: '/'; +$root = __DIR__ . '/../share/reverse-proxy/docroot/max25-websocket'; + +if ($uri === '/' || $uri === '/index.php') { + $ws_url = getenv('MAX25_DEV_WS_URL') ?: 'ws://127.0.0.1:7326/max25'; + require $root . '/index.php'; + return true; +} + +$file = $root . $uri; +if (is_file($file)) { + return false; +} + +http_response_code(404); +echo "not found\n"; +return true; diff --git a/stacks/web/scripts/dev-server.sh b/stacks/web/scripts/dev-server.sh new file mode 100755 index 0000000..00b9f0c --- /dev/null +++ b/stacks/web/scripts/dev-server.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# Local dev: max25-ws-proxy + PHP built-in server (direct WebSocket to loopback proxy). +set -euo pipefail + +SRC="$(cd "$(dirname "$0")/../../.." && pwd)" +WEB="$SRC/stacks/web" +DOCROOT="$WEB/share/reverse-proxy/docroot/max25-websocket" +PROXY_INI="${MAX25_WEB_PROXY_INI:-$WEB/share/web-proxy.ini.example}" +PHP_HOST="${MAX25_WEB_PHP_HOST:-127.0.0.1}" +PHP_PORT="${MAX25_WEB_PHP_PORT:-8080}" +PROXY_PORT="${MAX25_WEB_PROXY_PORT:-7326}" + +cleanup() { + if [[ -n "${PROXY_PID:-}" ]]; then + kill "$PROXY_PID" 2>/dev/null || true + fi +} +trap cleanup EXIT + +echo "MAX25 web dev" +echo " max25d expected on 127.0.0.1:7325 (start separately)" +echo " proxy ini: $PROXY_INI" +echo " WebSocket: ws://127.0.0.1:$PROXY_PORT/max25" +echo " PHP UI: http://$PHP_HOST:$PHP_PORT/" +echo "" + +python3 "$WEB/proxy/max25-ws-proxy.py" -c "$PROXY_INI" --port "$PROXY_PORT" & +PROXY_PID=$! +sleep 0.3 + +export MAX25_DEV_WS_URL="ws://127.0.0.1:${PROXY_PORT}/max25" +php -S "$PHP_HOST:$PHP_PORT" -t "$DOCROOT" "$WEB/scripts/dev-router.php" |
