Spaces:
Running
Running
Commit ·
c1bf580
1
Parent(s): f419fae
Fix DevData restore timing before JupyterLab startup
Browse filesAdded a bug fix to ensure DevData restoration occurs before starting JupyterLab, preventing potential runtime state corruption.
start.sh
CHANGED
|
@@ -890,6 +890,21 @@ start_jupyter_once() {
|
|
| 890 |
echo "JupyterLab started (PID: $JUPYTER_PID)"
|
| 891 |
}
|
| 892 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 893 |
# 10.5. Start JupyterLab Terminal on internal port 8888 (DEV_MODE only)
|
| 894 |
# Accessible via /terminal/ path through the health-server proxy
|
| 895 |
if [ "$RUNTIME_JUPYTER_ENABLED" = "true" ]; then
|
|
@@ -1458,6 +1473,13 @@ start_background_devdata_sync() {
|
|
| 1458 |
echo "DevData : script missing; skipped"
|
| 1459 |
return 0
|
| 1460 |
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1461 |
echo "DevData : enabled (dataset=${DEVDATA_DATASET_NAME:-huggingclaw-devdata})"
|
| 1462 |
python3 -u /home/node/app/jupyter-devdata-sync.py >> /tmp/devdata-sync.log 2>&1 &
|
| 1463 |
DEVDATA_SYNC_PID=$!
|
|
|
|
| 890 |
echo "JupyterLab started (PID: $JUPYTER_PID)"
|
| 891 |
}
|
| 892 |
|
| 893 |
+
# BUG FIX #3: DevData restore must happen BEFORE JupyterLab starts.
|
| 894 |
+
# The background jupyter-devdata-sync.py process is only launched AFTER the
|
| 895 |
+
# gateway is ready (20-90 s from now). If restore ran there, JupyterLab would
|
| 896 |
+
# already be live and the file writes would corrupt its runtime state → crash.
|
| 897 |
+
# Running --restore here (synchronous, before JupyterLab) solves that.
|
| 898 |
+
if [ "$RUNTIME_JUPYTER_ENABLED" = "true" ] && \
|
| 899 |
+
[ "$DEVDATA_ENABLED" = "true" ] && \
|
| 900 |
+
[ -n "${HF_TOKEN:-}" ] && \
|
| 901 |
+
[ -f "/home/node/app/jupyter-devdata-sync.py" ] && \
|
| 902 |
+
[ "${DEVDATA_DATASET_NAME:-huggingclaw-devdata}" != "${BACKUP_DATASET_NAME:-huggingclaw-backup}" ]; then
|
| 903 |
+
echo "DevData : restoring workspace from ${DEVDATA_DATASET_NAME:-huggingclaw-devdata} (before JupyterLab starts)..."
|
| 904 |
+
python3 /home/node/app/jupyter-devdata-sync.py --restore || \
|
| 905 |
+
echo "DevData : restore warning (non-fatal); continuing startup."
|
| 906 |
+
fi
|
| 907 |
+
|
| 908 |
# 10.5. Start JupyterLab Terminal on internal port 8888 (DEV_MODE only)
|
| 909 |
# Accessible via /terminal/ path through the health-server proxy
|
| 910 |
if [ "$RUNTIME_JUPYTER_ENABLED" = "true" ]; then
|
|
|
|
| 1473 |
echo "DevData : script missing; skipped"
|
| 1474 |
return 0
|
| 1475 |
fi
|
| 1476 |
+
# BUG FIX #1: Guard against spawning a second devdata-sync process on every
|
| 1477 |
+
# gateway restart. Without this check, each restart launched a fresh
|
| 1478 |
+
# jupyter-devdata-sync.py which called restore_once() while JupyterLab was
|
| 1479 |
+
# already running, corrupting its runtime state and killing it.
|
| 1480 |
+
if [ -n "${DEVDATA_SYNC_PID:-}" ] && kill -0 "$DEVDATA_SYNC_PID" 2>/dev/null; then
|
| 1481 |
+
return 0
|
| 1482 |
+
fi
|
| 1483 |
echo "DevData : enabled (dataset=${DEVDATA_DATASET_NAME:-huggingclaw-devdata})"
|
| 1484 |
python3 -u /home/node/app/jupyter-devdata-sync.py >> /tmp/devdata-sync.log 2>&1 &
|
| 1485 |
DEVDATA_SYNC_PID=$!
|