forked from mtusi2026/mtusi2026lab4
Перенесён стенд lab3 (API, Redis-сессии, идемпотентность, HAProxy, реплики API). Добавлены приватный bucket SeaweedFS с отдельным ключом API, загрузка PNG/JPEG с лимитами и полной проверкой, компенсация и reconciler, плавная остановка API, тесты и evidence.
29 lines
1.0 KiB
Bash
Executable File
29 lines
1.0 KiB
Bash
Executable File
#!/bin/sh
|
|
# s3-gw shares the network namespace of the `s3` container. When s3 restarts (crash,
|
|
# `docker restart`, Docker daemon restart) it gets a NEW namespace and this one is left
|
|
# with only `lo`: HAProxy keeps running but nothing can reach it. Exit in that case so
|
|
# the restart policy starts s3-gw again inside the current namespace of s3.
|
|
haproxy -W -db -f /usr/local/etc/haproxy/haproxy.cfg &
|
|
pid=$!
|
|
trap 'kill -TERM "$pid" 2>/dev/null' TERM INT USR1
|
|
|
|
orphaned() {
|
|
# /proc/net/dev: two header lines (with '|') and one line per interface.
|
|
! grep -qv -e '^ *lo:' -e '|' /proc/net/dev
|
|
}
|
|
|
|
while kill -0 "$pid" 2>/dev/null; do
|
|
if orphaned; then
|
|
echo "s3-gw: network namespace of s3 is gone; exiting so the restart policy re-joins it" >&2
|
|
kill -TERM "$pid" 2>/dev/null
|
|
wait "$pid"
|
|
# Docker does not retry a start that fails because s3 is not running yet:
|
|
# give the restart policy of s3 time to bring it back first.
|
|
sleep 5
|
|
exit 1
|
|
fi
|
|
sleep 2 &
|
|
wait $!
|
|
done
|
|
wait "$pid"
|