solstice-ci/.mise/tasks/run/orchestrator

38 lines
1.9 KiB
Text
Raw Permalink Normal View History

#!/usr/bin/env bash
set -euo pipefail
# Run the Solstice Orchestrator with sensible local defaults
# Default to info globally, but enable orchestrator debug to surface runner logs in CI
export RUST_LOG=${RUST_LOG:-info,orchestrator=debug}
export ORCH_CONFIG=${ORCH_CONFIG:-examples/orchestrator-image-map.yaml}
export AMQP_URL=${AMQP_URL:-amqp://127.0.0.1:5672/%2f}
export AMQP_EXCHANGE=${AMQP_EXCHANGE:-solstice.jobs}
export AMQP_QUEUE=${AMQP_QUEUE:-solstice.jobs.v1}
export AMQP_ROUTING_KEY=${AMQP_ROUTING_KEY:-jobrequest.v1}
export AMQP_PREFETCH=${AMQP_PREFETCH:-2}
export GRPC_ADDR=${GRPC_ADDR:-0.0.0.0:50051}
export DATABASE_URL=${DATABASE_URL:-postgres://solstice:solstice@127.0.0.1:5432/solstice}
# Detect a host IP reachable from VMs (prefer virbr0, fallback to 127.0.0.1)
if command -v ip >/dev/null 2>&1 && ip addr show virbr0 >/dev/null 2>&1; then
HOST_IP=$(ip -o -4 addr show virbr0 | awk '{print $4}' | cut -d/ -f1 | head -n1)
else
HOST_IP=${HOST_IP_OVERRIDE:-127.0.0.1}
fi
# Contact address for gRPC log streaming from guests (used in cloud-init)
export ORCH_CONTACT_ADDR=${ORCH_CONTACT_ADDR:-$HOST_IP:50051}
# Serve runner binaries directly from the orchestrator unless overridden
# Set RUNNER_DIR to a directory containing files:
# - solstice-runner (generic)
# - solstice-runner-linux (Linux-specific)
# - solstice-runner-illumos (Illumos-specific)
export RUNNER_DIR=${RUNNER_DIR:-target/runners}
# If user didn't provide external URLs, the orchestrator will compose URLs like
# http://$HOST_IP:${HTTP_PORT:-8081}/runners/solstice-runner[-linux|-illumos]
# automatically when RUNNER_DIR is set.
# To force external URLs instead, set SOLSTICE_RUNNER_URL(S) explicitly before running this task.
# For Linux + libvirt users, customize via LIBVIRT_URI and LIBVIRT_NETWORK
exec cargo run -p orchestrator --features libvirt -- \
--config "$ORCH_CONFIG" \
--grpc-addr "$GRPC_ADDR"