hindsight / scripts /entrypoint.sh
q1340's picture
Update scripts/entrypoint.sh
4a40ec0 verified
raw
history blame contribute delete
621 Bytes
#!/bin/bash
set -euo pipefail
# 启动 Hindsight
/app/start-all.sh &
HINDSIGHT_PID=$!
# 等待健康
for i in $(seq 1 60); do
if curl -sf http://localhost:7860/health > /dev/null 2>&1; then
break
fi
sleep 5
done
# 如果存在备份,直接在运行中的 PG 里恢复(不需要重启 Hindsight)
if [ -n "${HF_TOKEN:-}" ]; then
python3 /opt/backup/restore.py || true
fi
# 定期备份循环
while kill -0 "$HINDSIGHT_PID" 2>/dev/null; do
sleep "${BACKUP_INTERVAL_SECONDS:-21600}" &
wait $! || true
[ -n "${HF_TOKEN:-}" ] && python3 /opt/backup/backup.py scheduled || true
done