From 042526ea8c8e2592119189ac826cab15f3790dfc Mon Sep 17 00:00:00 2001 From: Stuart Axelbrooke Date: Tue, 25 Nov 2025 14:26:15 +0800 Subject: [PATCH] add multihop example script --- scripts/run_multihop_example.sh | 74 +++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100755 scripts/run_multihop_example.sh diff --git a/scripts/run_multihop_example.sh b/scripts/run_multihop_example.sh new file mode 100755 index 0000000..d3ee847 --- /dev/null +++ b/scripts/run_multihop_example.sh @@ -0,0 +1,74 @@ +#!/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