ci: restore polling heartbeat for buildx logs

This commit is contained in:
2026-05-15 16:18:59 +08:00
parent db458a9a14
commit 9c2767f78c
Vendored
+34 -6
View File
@@ -88,14 +88,28 @@ pipeline {
"\$@" >"\$log_file" 2>&1 & "\$@" >"\$log_file" 2>&1 &
cmd_pid=\$! cmd_pid=\$!
cmd_status=0 cmd_status=0
tail --pid="\$cmd_pid" -n +1 -f "\$log_file" & last_line=0
tail_pid=\$!
while kill -0 "\$cmd_pid" >/dev/null 2>&1; do while kill -0 "\$cmd_pid" >/dev/null 2>&1; do
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)" echo "[heartbeat] API multi-arch build still running at \$(date -u +%Y-%m-%dT%H:%M:%SZ)"
fi
sleep 20 sleep 20
done done
wait "\$cmd_pid" || cmd_status=\$? 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 if [ "\$cmd_status" -ne 0 ]; then
echo "[heartbeat] API multi-arch build failed with exit code \$cmd_status" echo "[heartbeat] API multi-arch build failed with exit code \$cmd_status"
fi fi
@@ -150,14 +164,28 @@ pipeline {
"\$@" >"\$log_file" 2>&1 & "\$@" >"\$log_file" 2>&1 &
cmd_pid=\$! cmd_pid=\$!
cmd_status=0 cmd_status=0
tail --pid="\$cmd_pid" -n +1 -f "\$log_file" & last_line=0
tail_pid=\$!
while kill -0 "\$cmd_pid" >/dev/null 2>&1; do while kill -0 "\$cmd_pid" >/dev/null 2>&1; do
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)" echo "[heartbeat] Web multi-arch build still running at \$(date -u +%Y-%m-%dT%H:%M:%SZ)"
fi
sleep 20 sleep 20
done done
wait "\$cmd_pid" || cmd_status=\$? 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 if [ "\$cmd_status" -ne 0 ]; then
echo "[heartbeat] Web multi-arch build failed with exit code \$cmd_status" echo "[heartbeat] Web multi-arch build failed with exit code \$cmd_status"
fi fi