#!/bin/bash
# usage: progress_live.sh <install prefix> <data dir> <port> <label>
set -e
P=$1; D=$2; PORT=$3; LABEL=$4
HERE=$(cd "$(dirname "$0")" && pwd)
rm -rf "$D"
"$P/bin/initdb" -D "$D" -U postgres >/dev/null 2>&1
"$P/bin/pg_ctl" -D "$D" -o "-p $PORT -k /tmp -c max_wal_size=4GB" -l "$D/log" -w start >/dev/null
trap '"$P/bin/pg_ctl" -D "$D" -m fast -w stop >/dev/null; rm -rf "$D"' EXIT
uv run --no-project --python 3.13 --with 'psycopg[binary]' python "$HERE/progress_live.py" "$PORT" "$LABEL" "${POLL:-0.005}"
