#!/bin/bash
port=8810

run_zego_visualizer() {
    fuser -k $port/tcp
    bazel run --config=cuda -c opt //zsaf/bayesian_optimization/tools:visualizer -- --server.port $port
}

until run_zego_visualizer; do
    echo "Service crashed with exit code $?. Restarting in 5 seconds..." >&2
    sleep 5
done
