managarten/services/mana-geocoding/photon-self
Till JS fc49198992 docs(geocoding): post-migration log + Photon weekly-refresh operator scripts
- 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>
2026-04-28 21:31:37 +02:00
..
photon-update.service docs(geocoding): post-migration log + Photon weekly-refresh operator scripts 2026-04-28 21:31:37 +02:00
photon-update.sh docs(geocoding): post-migration log + Photon weekly-refresh operator scripts 2026-04-28 21:31:37 +02:00
photon-update.timer docs(geocoding): post-migration log + Photon weekly-refresh operator scripts 2026-04-28 21:31:37 +02:00
README.md docs(geocoding): post-migration log + Photon weekly-refresh operator scripts 2026-04-28 21:31:37 +02:00

photon-self — operator files for the GPU-server Photon

Source-of-truth copies of the scripts and systemd units that run on mana-gpu to host the self-hosted Photon. Versioned here so the setup can be rebuilt in DR scenarios without recreating from memory.

What lives where

File Where it runs Purpose
photon-update.sh inside the WSL2 Ubuntu distro on mana-gpu, at /usr/local/bin/photon-update.sh Weekly index refresh — download new tarball, atomic swap, restart container, rollback on failure
photon-update.service /etc/systemd/system/photon-update.service Oneshot wrapper that invokes the script
photon-update.timer /etc/systemd/system/photon-update.timer Sunday 03:30 + 30-min jitter, persistent across reboots

Re-installation (after a clean Windows reinstall etc.)

After you've followed docs/runbooks/photon-on-mana-gpu.md to get WSL2 + Docker + the initial Photon container running:

# Run inside WSL2 Ubuntu as root:
cp /mnt/c/path/to/repo/services/mana-geocoding/photon-self/photon-update.sh \
   /usr/local/bin/photon-update.sh
chmod +x /usr/local/bin/photon-update.sh

cp /mnt/c/path/to/repo/services/mana-geocoding/photon-self/photon-update.service \
   /etc/systemd/system/
cp /mnt/c/path/to/repo/services/mana-geocoding/photon-self/photon-update.timer \
   /etc/systemd/system/

systemctl daemon-reload
systemctl enable --now photon-update.timer
systemctl list-timers photon-update.timer  # verify next run

Manual trigger

To force a refresh outside the schedule:

# Inside WSL2 Ubuntu as root
systemctl start photon-update.service
journalctl -u photon-update.service -f   # watch progress
tail -f /var/log/photon-update.log       # script-level detail

What the update script does

1. curl new tarball → /opt/photon-data/photon-db.tar.bz2.new
2. Verify size ≥ 25 GB (sanity guard against truncated downloads)
3. tar -xjf into /opt/photon-data/photon_data.new
4. docker stop photon
5. mv old → .old, mv new → live (atomic-ish — both renames in same FS)
6. docker start photon
7. Poll /api?q=Konstanz for up to 180 s
   - On success: rm -rf .old (cleanup)
   - On failure: rollback (mv live → .bad, mv .old → live, restart)

The rollback path is the load-bearing part — a corrupted GraphHopper dump or a Photon version-mismatch can otherwise leave the service in a non-serving state until the operator notices.

Why systemd timer instead of cron

WSL2 Ubuntu has systemd enabled by default since the 0.67.6 release. Timers give us:

  • Persistent=true — runs missed jobs at next boot if the GPU server was off Sunday morning. Cron just skips them.
  • RandomizedDelaySec=30min — spreads 100s of weekly jobs across the GraphHopper CDN window, polite-neighbour style.
  • journalctl -u photon-update — structured logs in one place.
  • Status-checkable with systemctl list-timers.

The downside (more files on disk than a single crontab entry) is negligible.