Add a host-side Python collector that lists every bank account, pages through all ledger rows, and emits stats.json with amount_alt fields (Kilo/Mega/Peta-GOA) so large ladder withdrawals fit on the landing tiles.
106 lines
3.8 KiB
Markdown
106 lines
3.8 KiB
Markdown
# taler-landing — central stats (hernani user systemd)
|
|
|
|
Public landing numbers on
|
|
|
|
- https://bank.hacktivism.ch/intro/ → `stats.json`
|
|
- https://exchange.hacktivism.ch/intro/ → `stats.json`
|
|
- https://taler.hacktivism.ch/intro/ → `stats.json`
|
|
|
|
are produced by **one host process** as user **`hernani`**, not by three unrelated in-container crons.
|
|
|
|
## Why host / user systemd
|
|
|
|
| Concern | Approach |
|
|
|--------|----------|
|
|
| **All accounts / all money** | Python full scan + tx pagination (not capped at 80 accounts) |
|
|
| **High ladder GOA** | `amount_alt` / UI alt units (Kilo-/Mega-/Peta-GOA) — tiles stay short |
|
|
| **No root cron** | `systemctl --user` as hernani + `loginctl enable-linger` |
|
|
| **Failure safety** | failed run only updates `stats-run.json`; last good `stats.json` stays |
|
|
|
|
## Install (on koopa as hernani)
|
|
|
|
```bash
|
|
cd ~/src/koopa/koopa-admin-log
|
|
./scripts/taler-landing/install-landing-stats-host.sh
|
|
|
|
# timer without login session:
|
|
sudo loginctl enable-linger hernani
|
|
|
|
# run once:
|
|
systemctl --user start taler-landing-stats.service
|
|
journalctl --user -u taler-landing-stats.service -n 50 --no-pager
|
|
systemctl --user list-timers 'taler-landing-stats*'
|
|
```
|
|
|
|
Units:
|
|
|
|
- `configs/systemd/user/taler-landing-stats.service` — oneshot collector
|
|
- `configs/systemd/user/taler-landing-stats.timer` — every **2 minutes** after boot
|
|
|
|
Installed paths:
|
|
|
|
| Path | Role |
|
|
|------|------|
|
|
| `~/.local/bin/collect-landing-stats.sh` | orchestrator |
|
|
| `~/.local/lib/taler-landing/*.py` | bank scan + alt enrich |
|
|
| `~/.local/state/taler-landing-stats/` | logs |
|
|
| `~/.config/systemd/user/taler-landing-stats.*` | user units |
|
|
|
|
## What the collector does
|
|
|
|
1. **Bank** — `collect_bank_stats.py`
|
|
- admin token → list **all** accounts
|
|
- for each account (except `SCAN_SKIP`, default **`exchange`**) page through **all** transactions
|
|
- sum credits / Taler withdraws / other debits
|
|
- emit `amount` + `amount_alt` / `amount_full`
|
|
- `podman cp` → `taler-hacktivism-bank:/var/www/bank-landing/stats.json`
|
|
|
|
2. **Exchange** — run `landing-stats-exchange.sh` inside exchange container, then **enrich** alt fields on the host and write back.
|
|
|
|
3. **Merchant** — same for merchant container.
|
|
|
|
`exchange` is skipped in the bank **flow** scan so the same GOA is not counted once as customer withdraw and again as exchange credit. **Admin**, **explorer**, and every auto-account are included.
|
|
|
|
## Secrets
|
|
|
|
Preferred order:
|
|
|
|
1. `~/src/koopa/koopa-admin-secrets/koopa/host-root/taler-bank/bank-admin-password.txt`
|
|
2. `~/.config/taler-landing/bank-*-password.txt`
|
|
3. `podman exec taler-hacktivism-bank cat /root/bank-admin-password.txt`
|
|
|
|
Explorer password optional (shared-pool balance).
|
|
|
|
## Env overrides
|
|
|
|
| Env | Default | Meaning |
|
|
|-----|---------|---------|
|
|
| `BANK_URL` | `http://127.0.0.1:9012` | libeufin loopback |
|
|
| `SCAN_SKIP` | `exchange` | usernames excluded from flow |
|
|
| `TX_PAGE` | `500` | transactions page size |
|
|
| `MAX_TX_PAGES` | `0` | `0` = unlimited pages / account |
|
|
| `ACCOUNTS_DELTA` | `-10000` | account list window |
|
|
| `ADMIN_LOG` | `%h/src/koopa/koopa-admin-log` | refresh in-container scripts |
|
|
|
|
## UI alt names
|
|
|
|
`configs/shared/goa-amount.js` formats large amounts as e.g. `1.23 Mega-GOA` (tooltip = full `GOA:…`). Landings load it as `/intro/goa-amount.js` (deploy via `deploy-landings.sh`).
|
|
|
|
## Legacy in-container bank cron
|
|
|
|
`scripts/taler-bank/landing-stats.sh` remains a **fallback** inside the bank container. Once the hernani timer is healthy, disable the old in-container minutely cron to avoid races:
|
|
|
|
```bash
|
|
podman exec taler-hacktivism-bank crontab -l # inspect
|
|
# remove landing-stats.sh line if present
|
|
```
|
|
|
|
## Manual run
|
|
|
|
```bash
|
|
~/.local/bin/collect-landing-stats.sh
|
|
# or from checkout:
|
|
./scripts/taler-landing/collect-landing-stats.sh
|
|
|
|
curl -sS https://bank.hacktivism.ch/intro/stats.json | python3 -m json.tool | head
|
|
```
|