Files
ljwx-deploy/apps/ljwx-health/schema-restore-drill/scripts/run-ephemeral-redis.sh
T
BrunoGao 5772d2f3d0 feat(restore): add application-level schema restore drill (#348)
* ops(health): smoke immutable app after schema restore

* ci: silence trap-only shellcheck paths
2026-08-01 02:07:42 +08:00

52 lines
1.1 KiB
Bash

#!/usr/bin/env sh
# shellcheck disable=SC2317,SC2329 # cleanup is invoked by signal and EXIT traps.
set -eu
cleanup() {
status=$?
trap - EXIT INT TERM
if [ -n "${redis_pid:-}" ] \
&& kill -0 "${redis_pid}" 2>/dev/null; then
kill "${redis_pid}" 2>/dev/null || true
wait "${redis_pid}" 2>/dev/null || true
fi
exit "${status}"
}
trap cleanup EXIT INT TERM
redis-server \
--bind 127.0.0.1 \
--port 6379 \
--protected-mode no \
--save '' \
--appendonly no \
--dir /tmp &
redis_pid=$!
for _ in $(seq 1 120); do
if redis-cli -h 127.0.0.1 -p 6379 ping 2>/dev/null \
| grep -q PONG; then
touch /evidence/redis-ready
break
fi
if ! kill -0 "${redis_pid}" 2>/dev/null; then
echo "ephemeral Redis exited before readiness" >&2
exit 1
fi
sleep 1
done
test -f /evidence/redis-ready
for _ in $(seq 1 2400); do
if [ -f /evidence/application-smoke-verified ]; then
exit 0
fi
if [ -f /evidence/application-smoke-error ]; then
exit 1
fi
sleep 1
done
echo "timed out waiting for restored application smoke" >&2
exit 1