Recover local Sendico session after BFF network restarts (#57)

This commit is contained in:
Stephan D committed 2026-10-19 12:34:37 +02:00
1 parent 021bd04324
commit 13cc9c302e
9 files changed
+158 -8

No files matched your search

+15 -4
View File
@@ -1,13 +1,24 @@
#!/bin/sh
set -eu
umask 077
# shellcheck source=infra/local/sendico/network.sh
. /etc/sendico/network.sh
mkdir -p /private /run/sendico
chmod 755 /run/sendico
cd /private
bridge=''; monitor=''; delay=''
cleanup() {
for child in "$bridge" "$monitor" "$delay"; do
if [ -n "$child" ]; then kill "$child" 2>/dev/null || true; fi
done
}
trap cleanup EXIT
trap 'exit 0' INT TERM
socat TCP4-LISTEN:18081,bind=127.0.0.1,reuseaddr,fork TCP4:host.docker.internal:8080 &
bridge=$!
trap 'kill "$bridge" 2>/dev/null || true' EXIT
trap 'exit 0' INT TERM
session_pid=$$
(trap - EXIT INT TERM; watch_network "$session_pid") &
monitor=$!
session() {
jq -n --rawfile role /etc/agent/role-id --rawfile secret /etc/agent/secret-id \
@@ -36,10 +47,10 @@ session() {
while :; do
if session; then
echo 'Local Sendico session ready; next renewal in 20 minutes.'
sleep 1200 & wait $!
sleep 1200 & delay=$!; wait "$delay"
else
echo 'Local Sendico session unavailable; check stand health and integration credentials. Retrying in 5 minutes.' >&2
rm -f request.json response.json token vault.header vault.json credentials.json login.json
sleep 300 & wait $!
sleep 300 & delay=$!; wait "$delay"
fi
done