feat: re-add daemonize to start.sh and loop waiting for ./readyz#391
feat: re-add daemonize to start.sh and loop waiting for ./readyz#391canercidam merged 1 commit intomainfrom
Conversation
|
Claude finished @fkondej's task in 1m 36s —— View job Review of PR #391
SummaryThis PR changes The overall approach is sound. Two minor issues flagged inline:
No bugs, security concerns, or correctness issues found. |
| while (( SECONDS < DEADLINE )); do | ||
| sleep 5 | ||
|
|
||
| # Fail fast if QEMU died (bad image, kernel panic, etc.) | ||
| if ! kill -0 "$(cat "${PIDFILE}")" 2>/dev/null; then | ||
| echo "Error: QEMU process died during boot" | ||
| echo " Check console log: tail -f ${CONSOLE_LOG}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| HTTP_CODE=$(curl -s -k -o /dev/null -w "%{http_code}" "${READYZ_URL}" 2>/dev/null || echo "000") | ||
| if [[ "${HTTP_CODE}" == "200" ]]; then | ||
| echo "VM ready after $(( READYZ_TIMEOUT - (DEADLINE - SECONDS) ))s (PID: $(cat "${PIDFILE}"))" | ||
| exit 0 | ||
| fi | ||
| echo " waiting... $(( READYZ_TIMEOUT - (DEADLINE - SECONDS) ))s (HTTP ${HTTP_CODE})" | ||
| done |
There was a problem hiding this comment.
The loop sleeps 5s before the first health check. If the VM is already ready (or becomes ready quickly), this adds an unnecessary delay. Consider checking first, then sleeping:
| while (( SECONDS < DEADLINE )); do | |
| sleep 5 | |
| # Fail fast if QEMU died (bad image, kernel panic, etc.) | |
| if ! kill -0 "$(cat "${PIDFILE}")" 2>/dev/null; then | |
| echo "Error: QEMU process died during boot" | |
| echo " Check console log: tail -f ${CONSOLE_LOG}" | |
| exit 1 | |
| fi | |
| HTTP_CODE=$(curl -s -k -o /dev/null -w "%{http_code}" "${READYZ_URL}" 2>/dev/null || echo "000") | |
| if [[ "${HTTP_CODE}" == "200" ]]; then | |
| echo "VM ready after $(( READYZ_TIMEOUT - (DEADLINE - SECONDS) ))s (PID: $(cat "${PIDFILE}"))" | |
| exit 0 | |
| fi | |
| echo " waiting... $(( READYZ_TIMEOUT - (DEADLINE - SECONDS) ))s (HTTP ${HTTP_CODE})" | |
| done | |
| while (( SECONDS < DEADLINE )); do | |
| # Fail fast if QEMU died (bad image, kernel panic, etc.) | |
| if ! kill -0 "$(cat "${PIDFILE}")" 2>/dev/null; then | |
| echo "Error: QEMU process died during boot" | |
| echo " Check console log: tail -f ${CONSOLE_LOG}" | |
| exit 1 | |
| fi | |
| HTTP_CODE=$(curl -s -k -o /dev/null -w "%{http_code}" "${READYZ_URL}" 2>/dev/null || echo "000") | |
| if [[ "${HTTP_CODE}" == "200" ]]; then | |
| echo "VM ready after $(( READYZ_TIMEOUT - (DEADLINE - SECONDS) ))s (PID: $(cat "${PIDFILE}"))" | |
| exit 0 | |
| fi | |
| echo " waiting... $(( READYZ_TIMEOUT - (DEADLINE - SECONDS) ))s (HTTP ${HTTP_CODE})" | |
| sleep 5 |
| echo "Error: VM did not become ready within ${READYZ_TIMEOUT}s" | ||
| echo " Check console log: tail -f ${CONSOLE_LOG}" | ||
| exit 1 |
There was a problem hiding this comment.
On timeout, the QEMU VM is still running in the background but the user isn't told. Consider adding a hint to run stop.sh:
| echo "Error: VM did not become ready within ${READYZ_TIMEOUT}s" | |
| echo " Check console log: tail -f ${CONSOLE_LOG}" | |
| exit 1 | |
| echo "Error: VM did not become ready within ${READYZ_TIMEOUT}s" | |
| echo " Check console log: tail -f ${CONSOLE_LOG}" | |
| echo " Stop the VM: ./scripts/stop.sh" | |
| exit 1 |
No description provided.