solstice-ci/.mise/tasks/run/runner-serve-multi
Till Wegmueller 0b54881558
Add support for multi-OS VM builds with cross-built runners and improved local development tooling
This commit introduces:
- Flexible runner URL configuration via `SOLSTICE_RUNNER_URL(S)` for cloud-init.
- Automated detection of OS-specific runner binaries during VM boot.
- Tasks for cross-building, serving, and orchestrating Solstice runners.
- End-to-end VM build flows for Linux and Illumos environments.
- Enhanced orchestration with multi-runner HTTP serving and log streaming.
2025-11-01 14:31:48 +01:00

53 lines
No EOL
2 KiB
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
# Serve cross-built workflow-runner binaries for Linux and Illumos on two ports.
# Intended for local development only.
# Env:
# SOL_RUNNER_BIND - bind address (default: 0.0.0.0)
# SOL_RUNNER_PORT_LINUX - port for Linux runner (default: 8090)
# SOL_RUNNER_PORT_ILLUMOS - port for Illumos runner (default: 8091)
# PYTHON - python interpreter (default: python3)
#
# Exposes:
# http://HOST:PORT/solstice-runner-linux
# http://HOST:PORT/solstice-runner-illumos
ROOT_DIR=$(cd "$(dirname "$0")/../../.." && pwd)
cd "$ROOT_DIR"
PYTHON=${PYTHON:-python3}
command -v "$PYTHON" >/dev/null 2>&1 || { echo "python3 is required" >&2; exit 127; }
# Ensure cross-built artifacts exist
if [[ ! -x "$ROOT_DIR/target/x86_64-unknown-linux-gnu/release/solstice-runner" || ! -x "$ROOT_DIR/target/x86_64-unknown-illumos/release/solstice-runner" ]]; then
echo "Cross-built runner binaries not found; building with cross..." >&2
"$ROOT_DIR/.mise/tasks/build/runner-cross"
fi
SERVE_DIR="$ROOT_DIR/target/runner-serve-multi"
rm -rf "$SERVE_DIR"
mkdir -p "$SERVE_DIR"
cp -f "$ROOT_DIR/target/x86_64-unknown-linux-gnu/release/solstice-runner" "$SERVE_DIR/solstice-runner-linux"
cp -f "$ROOT_DIR/target/x86_64-unknown-illumos/release/solstice-runner" "$SERVE_DIR/solstice-runner-illumos"
chmod +x "$SERVE_DIR/solstice-runner-linux" "$SERVE_DIR/solstice-runner-illumos" || true
BIND=${SOL_RUNNER_BIND:-0.0.0.0}
PORT_LIN=${SOL_RUNNER_PORT_LINUX:-8090}
PORT_ILL=${SOL_RUNNER_PORT_ILLUMOS:-8091}
echo "Serving from $SERVE_DIR" >&2
set +e
"$PYTHON" -m http.server "$PORT_LIN" --bind "$BIND" --directory "$SERVE_DIR" &
PID_LIN=$!
"$PYTHON" -m http.server "$PORT_ILL" --bind "$BIND" --directory "$SERVE_DIR" &
PID_ILL=$!
set -e
trap 'kill $PID_LIN $PID_ILL 2>/dev/null || true' INT TERM EXIT
echo "Linux runner: http://$BIND:$PORT_LIN/solstice-runner-linux" >&2
echo "Illumos runner: http://$BIND:$PORT_ILL/solstice-runner-illumos" >&2
# Wait on background servers
wait