mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-16 21:19:41 +02:00
- Decision report: status flipped to MIGRATED; added migration log with five WSL2 gotchas (bzip2 missing, no official Photon image, firewall=true blocks cross-LAN, vmIdleTimeout=-1 ineffective, PowerShell pre-expansion of bash $(...)) and resource snapshot. - mana-geocoding CLAUDE.md: PHOTON_SELF_API_URL note now reflects live primary status on mana-gpu since 2026-04-28. - photon-self/: operator scripts for the weekly DB refresh — update.sh (atomic-swap with rollback), systemd unit + timer (Sun 03:30 +30min jitter, Persistent=true), README with re-installation instructions for DR. Currently installed and enabled on mana-gpu. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
60 lines
1.9 KiB
Bash
Executable file
60 lines
1.9 KiB
Bash
Executable file
#!/bin/bash
|
|
# Weekly Photon DB update.
|
|
# - Downloads the latest tarball from GraphHopper
|
|
# - Verifies size before swapping (don't replace good data with a partial)
|
|
# - Atomic swap via mv → restart container
|
|
# - Keeps one previous version as .old in case of bad index
|
|
|
|
set -euo pipefail
|
|
|
|
DATA_DIR=/opt/photon-data
|
|
URL=https://download1.graphhopper.com/public/europe/photon-db-europe-1.0-latest.tar.bz2
|
|
MIN_SIZE=$((25 * 1024 * 1024 * 1024)) # 25 GB minimum, real one is ~29 GB
|
|
LOG=/var/log/photon-update.log
|
|
|
|
exec >>"$LOG" 2>&1
|
|
echo "=== $(date -Iseconds) — photon-update starting ==="
|
|
|
|
cd "$DATA_DIR"
|
|
|
|
# Download to .new — don't touch the live tarball
|
|
curl --silent --show-error --output photon-db.tar.bz2.new "$URL"
|
|
ACTUAL=$(stat -c %s photon-db.tar.bz2.new)
|
|
if [ "$ACTUAL" -lt "$MIN_SIZE" ]; then
|
|
echo "FAIL: downloaded tarball only $((ACTUAL / 1024 / 1024)) MB, expected ≥25 GB. Aborting."
|
|
rm -f photon-db.tar.bz2.new
|
|
exit 1
|
|
fi
|
|
echo "Downloaded $((ACTUAL / 1024 / 1024)) MB OK"
|
|
|
|
# Unpack to a fresh dir alongside the live one
|
|
rm -rf photon_data.new
|
|
mkdir photon_data.new
|
|
tar -xjf photon-db.tar.bz2.new -C photon_data.new --strip-components=1
|
|
|
|
# Stop the container, swap, restart
|
|
docker stop photon
|
|
mv photon_data photon_data.old || true
|
|
mv photon_data.new photon_data
|
|
mv photon-db.tar.bz2 photon-db.tar.bz2.old || true
|
|
mv photon-db.tar.bz2.new photon-db.tar.bz2
|
|
docker start photon
|
|
|
|
# Wait for it to come up + smoke
|
|
for i in $(seq 1 90); do
|
|
if curl -fsS --max-time 2 http://localhost:2322/api?q=Konstanz >/dev/null 2>&1; then
|
|
echo "OK — Photon ready after $i seconds with new index"
|
|
# Cleanup old version on success
|
|
rm -rf photon_data.old photon-db.tar.bz2.old
|
|
echo "=== $(date -Iseconds) — photon-update complete ==="
|
|
exit 0
|
|
fi
|
|
sleep 2
|
|
done
|
|
|
|
echo "FAIL — Photon did not become ready within 180 s after swap. Rolling back."
|
|
docker stop photon
|
|
mv photon_data photon_data.bad
|
|
mv photon_data.old photon_data
|
|
docker start photon
|
|
exit 1
|