harb/scripts/wait-for-service.sh
johba e5e1308e72 refactor: consolidate CI and local dev orchestration (#108)
## Summary
- Extract shared bootstrap functions into `scripts/bootstrap-common.sh` (eliminates ~120 lines of duplicated forge/cast commands from e2e.yml)
- Create reusable `scripts/wait-for-service.sh` for health checks (replaces 60-line inline wait-for-stack)
- Merge dev and CI entrypoints into unified scripts branching on `CI` env var (delete `docker/ci-entrypoints/`)
- Replace 4 per-service CI Dockerfiles with parameterized `docker/Dockerfile.service-ci`
- Add `sync-tax-rates.mjs` to CI image builder stage
- Fix: CI now grants txnBot recenter access (was missing)
- Fix: txnBot funding parameterized (CI=10eth, local=1eth)
- Delete 5 obsolete migration docs and 4 DinD integration files

Net: -1540 lines removed

Closes #107

## Test plan
- [ ] E2E pipeline passes (bootstrap sources shared script, services use old images with commands override)
- [ ] build-ci-images pipeline builds all 4 services with unified Dockerfile
- [ ] Local dev stack boots via `./scripts/dev.sh start`

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: openhands <openhands@all-hands.dev>
Reviewed-on: https://codeberg.org/johba/harb/pulls/108
2026-02-03 12:07:28 +01:00

26 lines
738 B
Bash
Executable file

#!/usr/bin/env bash
# Wait for an HTTP service to respond with 2xx.
# Usage: wait-for-service.sh <url> [timeout_seconds] [label]
set -euo pipefail
URL="${1:?Usage: wait-for-service.sh <url> [timeout_seconds] [label]}"
TIMEOUT="${2:-120}"
LABEL="${3:-$URL}"
INTERVAL=5
ATTEMPTS=$((TIMEOUT / INTERVAL))
if (( ATTEMPTS < 1 )); then ATTEMPTS=1; fi
for i in $(seq 1 "$ATTEMPTS"); do
if curl -sf --max-time 3 "$URL" > /dev/null 2>&1; then
echo "[wait] $LABEL healthy after $((i * INTERVAL))s"
exit 0
fi
echo "[wait] ($i/$ATTEMPTS) $LABEL not ready..."
sleep "$INTERVAL"
done
echo "[wait] ERROR: $LABEL not healthy after ${TIMEOUT}s"
echo "--- Diagnostic: $URL ---"
curl -v --max-time 5 "$URL" 2>&1 | head -20 || true
exit 1