From f19ef1cfd2670f458aa9f48253f911a653f25416 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Mon, 20 Jul 2026 06:04:49 +0000 Subject: [PATCH] docker: detach the notebook network refresh from container startup The GitHub refresh phase ran synchronously in the entrypoint's notebook sync, so an offline or slow network could hold container startup for up to two fetch timeouts (ls-remote + clone, about two minutes at the defaults) despite the sync being described as non-blocking. The local template populate and the categorized view still run in the foreground; the refresh now re-enters itself as a detached child (guarded by a flag so it forks once), whose phase-1 pass no-ops via the hash state and whose finalize is idempotent. Verified with an unreachable remote and an 8 second timeout: the parent returns in under a second with the notebooks populated while the child owns the waiting. --- docker/unsloth_sync_notebooks.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docker/unsloth_sync_notebooks.sh b/docker/unsloth_sync_notebooks.sh index 78de1e1b77..a164effcf1 100644 --- a/docker/unsloth_sync_notebooks.sh +++ b/docker/unsloth_sync_notebooks.sh @@ -172,9 +172,17 @@ if [ -f "$STATE" ] && [ "${UNSLOTH_KEEP_DELETED_NOTEBOOKS:-0}" != "1" ]; then fi # 2) Best-effort GitHub refresh -- only when upstream has advanced. Edits win. +# Detached: the local populate above already ran, and the refresh can spend up +# to 2x TIMEOUT on ls-remote + clone when offline, which must not delay +# container startup. The child re-enters past phase 1 (hash state makes it a +# no-op) and the flag keeps it from forking again. [ "${UNSLOTH_SKIP_NOTEBOOK_REFRESH:-0}" = "1" ] && exit 0 command -v git >/dev/null 2>&1 || exit 0 command -v sha256sum >/dev/null 2>&1 || exit 0 +if [ "${UNSLOTH_NB_REFRESH_CHILD:-0}" != "1" ]; then + UNSLOTH_NB_REFRESH_CHILD=1 "$0" >/dev/null 2>&1 & + exit 0 +fi last="$(cat "$SYNCED" 2>/dev/null || true)" remote="$(timeout "$TIMEOUT" git ls-remote "$REMOTE" HEAD 2>/dev/null | cut -f1)"