Files
ecs-relay-service/patch-source/0de3db40fc2044b0/hainuo-relay/scripts/update-h5.sh

33 lines
1.4 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
test -f .env || { echo 'Run inside the existing deployment; .env missing.'; exit 1; }
test -d wheelhouse || { echo 'Existing offline wheelhouse missing.'; exit 1; }
backup_tag="hainuo-relay:before-h5-$(date +%Y%m%d-%H%M%S)"
docker image tag hainuo-relay:0.1.0 "$backup_tag"
echo "Rollback image: $backup_tag"
# Offline dependencies are unchanged; do not pull images or initialize a new database.
docker build --network none --pull=false -f Dockerfile.offline -t hainuo-relay:0.1.0 .
cat > compose.h5.yaml <<'YAML'
services:
connector:
environment:
HN_REQUEST_TIMEOUT: "180"
YAML
args=(-f compose.yaml -f compose.offline.yaml)
if [ -f compose.edge-fix.yaml ]; then args+=(-f compose.edge-fix.yaml); fi
args+=(-f compose.h5.yaml)
docker compose "${args[@]}" config --quiet
docker compose "${args[@]}" up -d --no-build --pull never --no-deps --force-recreate connector
for attempt in {1..30}; do
if docker compose "${args[@]}" exec -T connector python -c \
"import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/ready',timeout=2)" 2>/dev/null; then
docker compose "${args[@]}" exec -T connector python -c \
"import urllib.request; t=urllib.request.urlopen('http://127.0.0.1:8000/h5').read(); assert b'pair-form' in t; print('H5 pairing/chat revision is ready')"
exit 0
fi
sleep 2
done
echo 'Connector not ready. Read: sudo docker compose logs --tail 80 connector'
exit 1