deploy.sh and the nightly resume leave the edge stopped while .cache/no-edge exists (range by range it would split releases at every edge with no merger left). deploy/replay-window.sh takes DB and OUT and passes REPLAY_INTO_CATALOG=1, which lets replay:corpus write a database not named *_replay or *_scratch (never the test one). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
68 lines
2.9 KiB
Bash
Executable File
68 lines
2.9 KiB
Bash
Executable File
#!/bin/sh
|
|
# Deploys voyager 2 (branch rebuild) on homelab at one commit. Installed as
|
|
# ~/bin/deploy-usenet-rebuild (by hand: it doesn't update itself). Gitea CI
|
|
# runs it through the forced SSH command of the deploy key, as
|
|
# "deploy-rebuild <sha>" (~/bin/deploy-usenet-indexer passes that on); by
|
|
# hand: deploy-usenet-rebuild <sha>. The code comes from the Gitea repo, not
|
|
# from the CI job.
|
|
set -eu
|
|
|
|
REPO=https://gitea.exp.sforum.nl/daan/usenet-indexer.git
|
|
BRANCH=rebuild
|
|
ROOT=/mnt/bulk/usenet-rebuild
|
|
CACHE="$ROOT/.cache"
|
|
GIT="$CACHE/repo.git"
|
|
|
|
SHA="${1:-}"
|
|
case "$SHA" in
|
|
*[!0-9a-f]* | "") echo "usage: deploy-usenet-rebuild <40-character commit sha>" >&2; exit 2 ;;
|
|
esac
|
|
[ "${#SHA}" -eq 40 ] || { echo "usage: deploy-usenet-rebuild <40-character commit sha>" >&2; exit 2; }
|
|
|
|
mkdir -p "$CACHE"
|
|
# One deploy at a time; a second one waits.
|
|
exec 9>"$CACHE/deploy.lock"
|
|
flock 9
|
|
|
|
echo "== fetching $SHA"
|
|
[ -d "$GIT" ] || git clone --quiet --bare "$REPO" "$GIT"
|
|
git -C "$GIT" fetch --quiet --prune "$REPO" '+refs/heads/*:refs/heads/*'
|
|
git -C "$GIT" cat-file -e "$SHA^{commit}"
|
|
git -C "$GIT" merge-base --is-ancestor "$SHA" "refs/heads/$BRANCH" || { echo "$SHA is not on $BRANCH" >&2; exit 2; }
|
|
|
|
STAGE=$(mktemp -d)
|
|
trap 'rm -rf "$STAGE"' EXIT
|
|
git -C "$GIT" archive "$SHA" | tar -x -C "$STAGE"
|
|
rsync -a --delete "$STAGE"/ "$ROOT/src/"
|
|
install -m 644 "$ROOT/src/deploy/compose.yaml" "$ROOT/compose.yaml"
|
|
|
|
cd "$ROOT"
|
|
echo "== building images"
|
|
docker compose build migrate edge
|
|
echo "== running migrations"
|
|
docker compose run --rm --no-deps migrate
|
|
# Only the app services, never postgres. The worker first: one holding a
|
|
# stream keeps the node API from exiting.
|
|
echo "== recreating app services"
|
|
docker compose stop edge
|
|
if [ -e "$CACHE/paused" ]; then
|
|
# Paused for the night (~/bin/usenet-rebuild-pause.sh): the workers stay stopped, the resume starts the new build.
|
|
echo "== paused: coordinator, prober, merger, judge, spotter, spot-inspector and edge left stopped"
|
|
docker compose up -d --no-deps node-api web
|
|
else
|
|
docker compose up -d --no-deps node-api web coordinator prober merger judge spotter spot-inspector
|
|
if [ -e "$CACHE/no-edge" ]; then
|
|
# Voyager 3 (2026-10-26, LOG.md (116)): the worker indexes range by range, without the carried window, and
|
|
# would split releases at every range edge with nothing to join them; history comes from the corpus through
|
|
# deploy/replay-window.sh until the window worker is built. Remove the marker to start it again.
|
|
echo "== no-edge: the edge worker left stopped"
|
|
else
|
|
docker compose up -d --no-deps edge
|
|
fi
|
|
fi
|
|
echo "$SHA $(date -Is)" >> "$ROOT/deployed.log"
|
|
# The images this replaced (321 MB each; the root filesystem is the NVMe, with a 10 GB floor).
|
|
docker image prune -f --filter label=com.docker.compose.project=usenet-rebuild >/dev/null
|
|
docker compose ps --format '{{.Service}} {{.Status}}' node-api web coordinator prober merger judge spotter spot-inspector edge
|
|
echo "== deployed $SHA"
|