fix: run build in screen session to survive SSH disconnects

Long builds (NVIDIA driver download+compile) would abort on SSH timeout.
Now build runs in a detached screen session on the VM, run-builder.sh
streams the log and waits for completion safely.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 18:07:17 +03:00
parent d4a2d7fa55
commit e5c1ef2c33
2 changed files with 25 additions and 5 deletions

View File

@@ -37,7 +37,8 @@ apk add \
wget \
curl \
tar \
xz
xz \
screen
# --- audit runtime packages (verify they exist in Alpine repos) ---
echo ""

View File

@@ -35,9 +35,10 @@ echo "=== bee builder ==="
echo "Builder: ${BUILDER_HOST}"
echo ""
ssh -o StrictHostKeyChecking=no root@"${BUILDER_HOST}" /bin/sh <<EOF
ssh -o StrictHostKeyChecking=no root@"${BUILDER_HOST}" /bin/sh <<ENDSSH
set -e
REPO=/root/bee
LOG=/var/log/bee-build.log
if [ ! -d "\$REPO/.git" ]; then
echo "--- cloning bee repo ---"
@@ -48,9 +49,27 @@ cd "\$REPO"
echo "--- pulling latest ---"
git pull --ff-only
echo "--- running build ---"
sh iso/builder/build-debug.sh ${EXTRA_ARGS}
EOF
# Kill any previous build session
screen -S bee-build -X quit 2>/dev/null || true
echo "--- starting build in screen session (survives SSH disconnect) ---"
echo "--- log: \$LOG ---"
screen -dmS bee-build sh -c "sh iso/builder/build-debug.sh ${EXTRA_ARGS} > \$LOG 2>&1; echo \$? > /tmp/bee-build-exit"
# Stream log until build finishes
echo "--- streaming build log (Ctrl+C safe — build continues on VM) ---"
while screen -list | grep -q bee-build; do
tail -n +1 -f "\$LOG" 2>/dev/null & TAIL_PID=\$!
sleep 1
while screen -list | grep -q bee-build; do sleep 2; done
kill \$TAIL_PID 2>/dev/null || true
break
done
tail -n 20 "\$LOG" 2>/dev/null || true
EXIT_CODE=\$(cat /tmp/bee-build-exit 2>/dev/null || echo 1)
exit \$EXIT_CODE
ENDSSH
echo ""
echo "=== downloading ISO ==="