ops: GOA vanilla landings stats wdGet + collect greening
This commit is contained in:
parent
0d881cd726
commit
337d253691
24 changed files with 1074 additions and 107 deletions
|
|
@ -14,61 +14,86 @@ podman exec -u root "$CTR" chmod 755 \
|
|||
/usr/local/bin/auto-confirm-withdrawals.sh \
|
||||
/usr/local/bin/refresh-demo-withdraw.sh
|
||||
|
||||
# nginx: proxy demo-withdraw.json
|
||||
NGX=/etc/nginx/sites-available/bank-landing
|
||||
# nginx: ensure demo-withdraw / auto-account / Integration → :19096
|
||||
# FP pattern: Caddy @wdGet GET → :9013 → this location → demo-api
|
||||
# (single in-CTR python; no nested podman)
|
||||
podman exec -u root "$CTR" bash -lc '
|
||||
set -e
|
||||
f=/etc/nginx/sites-available/bank-landing
|
||||
if ! grep -q demo-withdraw.json "$f"; then
|
||||
# insert before location /intro/
|
||||
python3 - <<PY
|
||||
python3 - <<PY
|
||||
from pathlib import Path
|
||||
p=Path("/etc/nginx/sites-available/bank-landing")
|
||||
t=p.read_text()
|
||||
block=""" location = /intro/demo-withdraw.json {
|
||||
p = Path("/etc/nginx/sites-available/bank-landing")
|
||||
t = p.read_text()
|
||||
changed = False
|
||||
anchor = " location /intro/ {"
|
||||
blocks = []
|
||||
if "demo-withdraw.json" not in t:
|
||||
blocks.append(""" location = /intro/demo-withdraw.json {
|
||||
proxy_pass http://127.0.0.1:19096/demo-withdraw.json;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host \$host;
|
||||
add_header Cache-Control "no-store" always;
|
||||
add_header Access-Control-Allow-Origin * always;
|
||||
}
|
||||
"""
|
||||
if "demo-withdraw.json" not in t:
|
||||
t=t.replace(" location /intro/ {", block+" location /intro/ {", 1)
|
||||
p.write_text(t)
|
||||
print("nginx location added")
|
||||
""")
|
||||
print("nginx demo-withdraw location added")
|
||||
else:
|
||||
print("nginx already has demo-withdraw")
|
||||
if "auto-account.json" not in t:
|
||||
t=p.read_text()
|
||||
block2=""" location = /intro/auto-account.json {
|
||||
blocks.append(""" location = /intro/auto-account.json {
|
||||
proxy_pass http://127.0.0.1:19096/auto-account.json;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host \$host;
|
||||
add_header Cache-Control "no-store" always;
|
||||
add_header Access-Control-Allow-Origin * always;
|
||||
}
|
||||
"""
|
||||
t=t.replace(" location /intro/ {", block2+" location /intro/ {", 1)
|
||||
p.write_text(t)
|
||||
""")
|
||||
print("nginx auto-account location added")
|
||||
else:
|
||||
print("nginx already has auto-account")
|
||||
if "taler-integration/withdrawal-operation" not in t:
|
||||
blocks.append(""" # FP pattern: GET Integration via demo-api (suggested/required_exchange)
|
||||
# Caddy @wdGet → :9013 → here → :19096; POST/other stays on :9012
|
||||
location /taler-integration/withdrawal-operation/ {
|
||||
proxy_pass http://127.0.0.1:19096;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host \$host;
|
||||
proxy_read_timeout 70s;
|
||||
add_header Cache-Control "no-store" always;
|
||||
add_header Access-Control-Allow-Origin * always;
|
||||
}
|
||||
""")
|
||||
print("nginx Integration withdrawal-operation location added")
|
||||
else:
|
||||
print("nginx already has Integration withdrawal-operation")
|
||||
if blocks:
|
||||
if anchor not in t:
|
||||
raise SystemExit("nginx anchor location /intro/ not found")
|
||||
t = t.replace(anchor, "".join(blocks) + anchor, 1)
|
||||
p.write_text(t)
|
||||
changed = True
|
||||
if not changed:
|
||||
print("nginx locations already complete")
|
||||
PY
|
||||
nginx -t && nginx -s reload || true
|
||||
else
|
||||
echo "nginx already configured"
|
||||
fi
|
||||
nginx -t && nginx -s reload || true
|
||||
'
|
||||
|
||||
# start/restart API + single auto-confirm loop (flock inside script)
|
||||
podman exec -u root "$CTR" bash -lc '
|
||||
# stop demo-withdraw by pid (avoid pkill -f self-match)
|
||||
# stop demo-withdraw by pid (avoid pkill -f self-match); wait for :19096
|
||||
ps -eo pid=,args= | awk "/demo-withdraw-api\\.py/ && !/awk/ {print \$1}" | while read p; do kill \$p 2>/dev/null || true; done
|
||||
sleep 0.3
|
||||
sleep 1
|
||||
ps -eo pid=,args= | awk "/demo-withdraw-api\\.py/ && !/awk/ {print \$1}" | while read p; do kill -9 \$p 2>/dev/null || true; done
|
||||
sleep 0.5
|
||||
nohup python3 /usr/local/bin/demo-withdraw-api.py \
|
||||
>>/var/log/demo-withdraw-api.log 2>&1 </dev/null &
|
||||
echo "api pid $!"
|
||||
# fail loud if bind lost to a leftover listener
|
||||
sleep 0.5
|
||||
ps -eo pid=,args= | awk "/demo-withdraw-api\\.py/ && !/awk/" || {
|
||||
echo "ERROR: demo-withdraw-api failed to stay up (port busy?)" >&2
|
||||
tail -20 /var/log/demo-withdraw-api.log >&2 || true
|
||||
exit 1
|
||||
}
|
||||
# stop auto-confirm by pid
|
||||
ps -eo pid=,args= | awk "/auto-confirm-withdrawals\\.sh --loop/ && !/awk/ {print \$1}" | while read p; do kill \$p 2>/dev/null || true; done
|
||||
sleep 0.5
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue