#!/usr/bin/env bash set -euo pipefail # Navigate to repository root cd "$(dirname "$0")/.." # Configuration PORT=3050 DB_PATH="/tmp/databuild_multihop.db" FLAG_FILE="/tmp/databuild_multihop_alpha_complete" PID_FILE="/tmp/databuild_multihop.pid" echo "=== DataBuild Multi-Hop Example ===" echo # Clean up previous state echo "Cleaning up previous state..." rm -f "$DB_PATH" "$FLAG_FILE" "$PID_FILE" pkill -f "databuild.*serve.*port $PORT" || true sleep 1 # Build the binary echo "Building databuild CLI..." bazel build //databuild:databuild # Start the server in background echo "Starting databuild server on port $PORT..." ./bazel-bin/databuild/databuild serve \ --port $PORT \ --database "$DB_PATH" \ --config examples/multihop/config.json & SERVER_PID=$! echo $SERVER_PID > "$PID_FILE" echo "Server started with PID $SERVER_PID" # Wait for server to be ready echo "Waiting for server to start..." sleep 2 # Test server health if curl -s http://localhost:$PORT/health > /dev/null 2>&1; then echo "Server is ready!" else echo "WARNING: Server health check failed, but continuing..." fi echo echo "=== Server is running ===" echo echo "You can now interact with the server:" echo echo " # Create a want for data/beta (triggers dependency chain)" echo " ./bazel-bin/databuild/databuild --server http://localhost:$PORT want data/beta" echo echo " # Monitor wants" echo " ./bazel-bin/databuild/databuild --server http://localhost:$PORT wants list" echo echo " # Monitor job runs" echo " ./bazel-bin/databuild/databuild --server http://localhost:$PORT job-runs list" echo echo " # Monitor partitions" echo " ./bazel-bin/databuild/databuild --server http://localhost:$PORT partitions list" echo echo "To stop the server:" echo " kill $SERVER_PID" echo " # or: pkill -f 'databuild.*serve.*port $PORT'" echo echo "Server logs will appear below. Press Ctrl+C to stop." echo "==========================================" echo # Wait for the server process wait $SERVER_PID