Files
RustProxy/scripts/start_stream_backends.sh
T
2026-11-28 17:36:53 +01:00

41 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
HOST="${1:-127.0.0.1}"
PYTHON="${PYTHON:-python3}"
pids=()
for file in test_stream_tcp.py test_stream_udp.py; do
if [[ ! -f "$DIR/$file" ]]; then
echo "Missing $DIR/$file (place the launcher next to the two test scripts)" >&2
exit 1
fi
done
cleanup() {
trap - EXIT INT TERM
if ((${#pids[@]})); then
kill "${pids[@]}" 2>/dev/null || true
wait "${pids[@]}" 2>/dev/null || true
fi
}
trap cleanup EXIT
trap 'exit 130' INT
trap 'exit 143' TERM
"$PYTHON" "$DIR/test_stream_tcp.py" server --host "$HOST" --port 9101 --backend-id tcp-a & pids+=("$!")
"$PYTHON" "$DIR/test_stream_tcp.py" server --host "$HOST" --port 9102 --backend-id tcp-b & pids+=("$!")
"$PYTHON" "$DIR/test_stream_udp.py" server --host "$HOST" --port 9201 --backend-id udp-a & pids+=("$!")
"$PYTHON" "$DIR/test_stream_udp.py" server --host "$HOST" --port 9202 --backend-id udp-b & pids+=("$!")
printf '\nMock backends for RustProxy (bind: %s):\n' "$HOST"
printf 'TCP: %s:9101 (tcp-a), %s:9102 (tcp-b)\n' "$HOST" "$HOST"
printf 'UDP: %s:9201 (udp-a), %s:9202 (udp-b)\n' "$HOST" "$HOST"
printf 'UDP health probe: PING => PONG\n'
printf 'Stop: Ctrl+C\n\n'
wait -n "${pids[@]}"
echo 'A backend stopped; stopping all mock backends.' >&2
exit 1