ops: taler-bank auto-confirm + systemd units + README
This commit is contained in:
parent
281873a955
commit
7691ac3065
4 changed files with 89 additions and 13 deletions
|
|
@ -4,11 +4,15 @@
|
|||
# ./scripts/taler-bank/install-demo-withdraw-api.sh
|
||||
set -euo pipefail
|
||||
ROOT=$(cd "$(dirname "$0")" && pwd)
|
||||
CTR="${BANK_CONTAINER:-taler-hacktivism-bank}"
|
||||
CTR="${BANK_CONTAINER:-goa-regio-ng}"
|
||||
|
||||
podman cp "$ROOT/demo-withdraw-api.py" "$CTR:/usr/local/bin/demo-withdraw-api.py"
|
||||
podman cp "$ROOT/auto-confirm-withdrawals.sh" "$CTR:/usr/local/bin/auto-confirm-withdrawals.sh"
|
||||
podman cp "$ROOT/refresh-demo-withdraw.sh" "$CTR:/usr/local/bin/refresh-demo-withdraw.sh"
|
||||
if [ -f "$ROOT/systemd/goa-auto-confirm-withdrawals.service" ]; then
|
||||
podman cp "$ROOT/systemd/goa-auto-confirm-withdrawals.service" \
|
||||
"$CTR:/etc/systemd/system/goa-auto-confirm-withdrawals.service"
|
||||
fi
|
||||
podman exec -u root "$CTR" chmod 755 \
|
||||
/usr/local/bin/demo-withdraw-api.py \
|
||||
/usr/local/bin/auto-confirm-withdrawals.sh \
|
||||
|
|
@ -94,9 +98,7 @@ ps -eo pid=,args= | awk "/demo-withdraw-api\\.py/ && !/awk/" || {
|
|||
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
|
||||
# Prefer systemd unit (Restart=always). Fall back to nohup if systemctl missing.
|
||||
if [ -f /var/log/auto-confirm-withdrawals.log ]; then
|
||||
sz=$(wc -c </var/log/auto-confirm-withdrawals.log)
|
||||
if [ "${sz:-0}" -gt 5000000 ]; then
|
||||
|
|
@ -105,12 +107,22 @@ if [ -f /var/log/auto-confirm-withdrawals.log ]; then
|
|||
cat /tmp/ac-keep.log >> /var/log/auto-confirm-withdrawals.log
|
||||
fi
|
||||
fi
|
||||
nohup env QUIET=1 WATCH_MAX=80 \
|
||||
/usr/local/bin/auto-confirm-withdrawals.sh --loop 2 \
|
||||
>>/var/log/auto-confirm-withdrawals.log 2>&1 </dev/null &
|
||||
echo "auto-confirm pid $!"
|
||||
sleep 1
|
||||
ps -eo pid=,args= | awk "/auto-confirm-withdrawals\\.sh --loop/ && !/awk/"
|
||||
# stop ad-hoc loops (by pid; avoid pkill -f self-match)
|
||||
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
|
||||
if command -v systemctl >/dev/null 2>&1 && [ -f /etc/systemd/system/goa-auto-confirm-withdrawals.service ]; then
|
||||
systemctl daemon-reload
|
||||
systemctl enable --now goa-auto-confirm-withdrawals.service
|
||||
systemctl restart goa-auto-confirm-withdrawals.service
|
||||
systemctl --no-pager --full status goa-auto-confirm-withdrawals.service | head -20
|
||||
else
|
||||
nohup env QUIET=1 WATCH_MAX=80 \
|
||||
/usr/local/bin/auto-confirm-withdrawals.sh --loop 2 \
|
||||
>>/var/log/auto-confirm-withdrawals.log 2>&1 </dev/null &
|
||||
echo "auto-confirm pid $! (no systemd unit)"
|
||||
sleep 1
|
||||
ps -eo pid=,args= | awk "/auto-confirm-withdrawals\\.sh --loop/ && !/awk/"
|
||||
fi
|
||||
curl -sS -m 8 http://127.0.0.1:19096/demo-withdraw.json | head -c 300; echo
|
||||
'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue