File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,11 +50,25 @@ pre-agent-steps:
5050 echo "Server PID: $PID"
5151 - name : Wait for server readiness
5252 run : |
53- for i in {1..45}; do # 45 attempts × 3s = 135s max wait
54- STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:4321/gh-aw/)
55- [ "$STATUS" = "200" ] && echo "Server ready at http://localhost:4321/gh-aw/!" && break
56- echo "Waiting for server... ($i/45) (status: $STATUS)" && sleep 3
53+ MAX_WAIT=135 # 45 attempts × 3s = 135s max wait
54+ WAITED=0
55+ until curl -sf http://localhost:4321/gh-aw/ > /dev/null 2>&1; do
56+ # Check if the server process has already died
57+ if [ -f /tmp/server.pid ] && ! kill -0 "$(cat /tmp/server.pid)" 2>/dev/null; then
58+ echo "::error::Documentation server process died before becoming ready. Server log:"
59+ cat /tmp/preview.log
60+ exit 1
61+ fi
62+ WAITED=$((WAITED + 3))
63+ if [ $WAITED -ge $MAX_WAIT ]; then
64+ echo "::error::Documentation server did not start after ${MAX_WAIT}s. Server log:"
65+ cat /tmp/preview.log
66+ exit 1
67+ fi
68+ echo "Waiting for server... ($WAITED/${MAX_WAIT}s)"
69+ sleep 3
5770 done
71+ echo "Server ready at http://localhost:4321/gh-aw/!"
5872 - name : Detect bridge IP and write server URL
5973 run : |
6074 SERVER_IP=$(ip -4 route get 1.1.1.1 2>/dev/null | awk '{print $7; exit}')
You can’t perform that action at this time.
0 commit comments