21 lines
695 B
Bash
21 lines
695 B
Bash
# Restarting the network-owning BFF can strand this sidecar in its old namespace.
|
|
# Exiting the session process lets Docker rejoin the BFF's current namespace.
|
|
watch_network() {
|
|
network_parent=$1
|
|
case "$network_parent" in ''|*[!0-9]*) return 1;; esac
|
|
[ "$network_parent" -gt 0 ] || return 1
|
|
network_failures=0
|
|
while sleep 10; do
|
|
if timeout 5 getent hosts vault >/dev/null 2>&1; then
|
|
network_failures=0
|
|
continue
|
|
fi
|
|
network_failures=$((network_failures+1))
|
|
if [ "$network_failures" -ge 3 ]; then
|
|
echo 'Local Sendico network DNS unavailable; restarting session container to reattach BFF network.' >&2
|
|
kill -TERM "$network_parent" 2>/dev/null || true
|
|
return
|
|
fi
|
|
done
|
|
}
|