ci: restore polling heartbeat for buildx logs #3

Merged
nanxun merged 1 commits from codex/ci-heartbeat-fix into main 2026-05-15 16:21:39 +08:00
Vendored
+36 -8
View File
@@ -88,14 +88,28 @@ pipeline {
"\$@" >"\$log_file" 2>&1 &
cmd_pid=\$!
cmd_status=0
tail --pid="\$cmd_pid" -n +1 -f "\$log_file" &
tail_pid=\$!
last_line=0
while kill -0 "\$cmd_pid" >/dev/null 2>&1; do
echo "[heartbeat] API multi-arch build still running at \$(date -u +%Y-%m-%dT%H:%M:%SZ)"
if [ -f "\$log_file" ]; then
total_lines=\$(wc -l < "\$log_file" 2>/dev/null || echo 0)
else
total_lines=0
fi
if [ "\$total_lines" -gt "\$last_line" ]; then
sed -n "\$((last_line + 1)),\${total_lines}p" "\$log_file"
last_line=\$total_lines
else
echo "[heartbeat] API multi-arch build still running at \$(date -u +%Y-%m-%dT%H:%M:%SZ)"
fi
sleep 20
done
wait "\$cmd_pid" || cmd_status=\$?
wait "\$tail_pid" >/dev/null 2>&1 || true
if [ -f "\$log_file" ]; then
total_lines=\$(wc -l < "\$log_file" 2>/dev/null || echo 0)
if [ "\$total_lines" -gt "\$last_line" ]; then
sed -n "\$((last_line + 1)),\${total_lines}p" "\$log_file"
fi
fi
if [ "\$cmd_status" -ne 0 ]; then
echo "[heartbeat] API multi-arch build failed with exit code \$cmd_status"
fi
@@ -150,14 +164,28 @@ pipeline {
"\$@" >"\$log_file" 2>&1 &
cmd_pid=\$!
cmd_status=0
tail --pid="\$cmd_pid" -n +1 -f "\$log_file" &
tail_pid=\$!
last_line=0
while kill -0 "\$cmd_pid" >/dev/null 2>&1; do
echo "[heartbeat] Web multi-arch build still running at \$(date -u +%Y-%m-%dT%H:%M:%SZ)"
if [ -f "\$log_file" ]; then
total_lines=\$(wc -l < "\$log_file" 2>/dev/null || echo 0)
else
total_lines=0
fi
if [ "\$total_lines" -gt "\$last_line" ]; then
sed -n "\$((last_line + 1)),\${total_lines}p" "\$log_file"
last_line=\$total_lines
else
echo "[heartbeat] Web multi-arch build still running at \$(date -u +%Y-%m-%dT%H:%M:%SZ)"
fi
sleep 20
done
wait "\$cmd_pid" || cmd_status=\$?
wait "\$tail_pid" >/dev/null 2>&1 || true
if [ -f "\$log_file" ]; then
total_lines=\$(wc -l < "\$log_file" 2>/dev/null || echo 0)
if [ "\$total_lines" -gt "\$last_line" ]; then
sed -n "\$((last_line + 1)),\${total_lines}p" "\$log_file"
fi
fi
if [ "\$cmd_status" -ne 0 ]; then
echo "[heartbeat] Web multi-arch build failed with exit code \$cmd_status"
fi