fix(deploy): robust health check via node inside container
This commit is contained in:
@@ -75,16 +75,8 @@ fi
|
||||
|
||||
nginx -t 2>/dev/null && systemctl reload nginx 2>/dev/null || true
|
||||
|
||||
CONTAINER_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' memento-web 2>/dev/null || true)
|
||||
|
||||
for i in $(seq 1 24); do
|
||||
BODY=""
|
||||
if [ -n "$CONTAINER_IP" ]; then
|
||||
BODY=$(curl -sf --max-time 3 "http://${CONTAINER_IP}:3000/api/build-info" 2>/dev/null || true)
|
||||
fi
|
||||
if [ -z "$BODY" ]; then
|
||||
BODY=$(curl -sf --max-time 3 http://127.0.0.1:3000/api/build-info 2>/dev/null || true)
|
||||
fi
|
||||
BODY=$(docker compose exec -T memento-note node -e "require('http').get('http://localhost:3000/api/build-info',r=>{let d='';r.on('data',c=>d+=c);r.on('end',()=>{console.log(d);process.exit(0)})}).on('error',()=>process.exit(1))" 2>/dev/null || true)
|
||||
ACTUAL=$(echo "$BODY" | jq -r '.commit // empty' 2>/dev/null || true)
|
||||
if [ "$ACTUAL" = "$GIT_COMMIT" ]; then
|
||||
echo "OK build-info commit=$ACTUAL"
|
||||
|
||||
Reference in New Issue
Block a user