fix(avocet): start-api polls port instead of sleeping 1s — avoids false-success on slow start
This commit is contained in:
parent
682a958c28
commit
cd7bbd1dbf
1 changed files with 14 additions and 5 deletions
17
manage.sh
17
manage.sh
|
|
@ -272,11 +272,20 @@ case "$CMD" in
|
||||||
--host 127.0.0.1 --port "$API_PORT" \
|
--host 127.0.0.1 --port "$API_PORT" \
|
||||||
>> "$API_LOG" 2>&1 &
|
>> "$API_LOG" 2>&1 &
|
||||||
echo $! > "$API_PID_FILE"
|
echo $! > "$API_PID_FILE"
|
||||||
sleep 1
|
# Poll until port is actually bound (up to 10 s), not just process alive
|
||||||
if kill -0 "$(<"$API_PID_FILE")" 2>/dev/null; then
|
for _i in $(seq 1 20); do
|
||||||
|
sleep 0.5
|
||||||
|
if (echo "" >/dev/tcp/127.0.0.1/"$API_PORT") 2>/dev/null; then
|
||||||
success "Avocet API started → http://localhost:${API_PORT} (PID $(<"$API_PID_FILE"))"
|
success "Avocet API started → http://localhost:${API_PORT} (PID $(<"$API_PID_FILE"))"
|
||||||
else
|
break
|
||||||
error "API died. Check ${API_LOG}"
|
fi
|
||||||
|
if ! kill -0 "$(<"$API_PID_FILE")" 2>/dev/null; then
|
||||||
|
rm -f "$API_PID_FILE"
|
||||||
|
error "API died during startup. Check ${API_LOG}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if ! (echo "" >/dev/tcp/127.0.0.1/"$API_PORT") 2>/dev/null; then
|
||||||
|
error "API did not bind to port ${API_PORT} within 10 s. Check ${API_LOG}"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue