#!/usr/bin/env bash # Rebuild and run the index in the foreground. # # It follows a personal data server, holds what it finds, and serves that to # the query service. This terminal is where you watch things being taken in: # an account appearing, a repository being read, a survey reconciling what a # stream missed. # # The server is not in this repository. Run one from didbot, or play a # recording back with vibescrobble-replay. set -euo pipefail cd "$(dirname "$0")/.." . "$(dirname "$0")/dev-watch.sh" . "$(dirname "$0")/dev-pds-url.sh" PORT="${VIBESCROBBLE_INDEX_PORT:-3002}" say() { printf '\033[1m%s\033[0m\n' "$*"; } # `--watch` reruns this script whenever the source moves. It never returns. watch_or_continue "$@" say "building" cargo test --quiet -p vibescrobble-index # Warned about rather than waited for. The index runs perfectly well with the # server down — it retries — and blocking here would make the order the # terminals are started in matter, which it should not. if ! pds_curl -sf "${PDS_URL}/health" >/dev/null 2>&1; then say "note: no personal data server answering at ${PDS_URL}" echo " the index will keep trying; start one from didbot, or replay a" echo " recording with ./target/debug/vibescrobble-replay serve" echo fi # Always, here. A development index is restarted far more often than its # population turns over, so every start would otherwise draw an empty canvas # beside a server full of history until somebody scrobbled. `--backfill` reads # every repository the server holds before it starts following, which on a # development population is a fraction of a second. # # It stays off everywhere else: a deployment runs the binary without this # script, follows a relay it cannot enumerate anyway, and is restarted rarely # enough that a stream is the whole answer. say "reading every repository on ${PDS_URL} before following it" exec cargo run --quiet -p vibescrobble-index --bin vibescrobble-index -- \ --pds "${PDS_URL}" --listen "127.0.0.1:${PORT}" --backfill "$@"