Spaces:
Running
Running
openhands commited on
Commit ·
8e7fdb4
1
Parent(s): 765a9cd
fix: improve JupyterLab restart logic with better error logging
Browse files- Add debug logging when JupyterLab crashes
- Fix PID tracking across gateway restarts
- Clear JUPYTER_PID before restart attempt
- Log last lines from jupyterlab.log on crash
start.sh
CHANGED
|
@@ -858,13 +858,14 @@ start_jupyter_once() {
|
|
| 858 |
fi
|
| 859 |
fi
|
| 860 |
|
| 861 |
-
# Pre-
|
| 862 |
-
|
| 863 |
-
mkdir -p "$JUPYTER_ROOT_DIR/.jupyter"
|
| 864 |
-
fi
|
| 865 |
|
| 866 |
echo "DEV_MODE enabled (${DEV_MODE_RAW}) — starting JupyterLab terminal on internal port 8888 (path: /terminal/) with root: $JUPYTER_ROOT_DIR"
|
| 867 |
JUPYTER_LOG_FILE="/tmp/jupyterlab.log"
|
|
|
|
|
|
|
|
|
|
| 868 |
python3 -m jupyterlab \
|
| 869 |
--ip 127.0.0.1 \
|
| 870 |
--port 8888 \
|
|
@@ -883,9 +884,10 @@ start_jupyter_once() {
|
|
| 883 |
--LabApp.check_for_updates_class=jupyterlab.NeverCheckForUpdate \
|
| 884 |
--ServerApp.quiet=True \
|
| 885 |
--ServerApp.log_level=WARNING \
|
| 886 |
-
--
|
| 887 |
>> "$JUPYTER_LOG_FILE" 2>&1 &
|
| 888 |
JUPYTER_PID=$!
|
|
|
|
| 889 |
echo "JupyterLab started (PID: $JUPYTER_PID)"
|
| 890 |
}
|
| 891 |
|
|
@@ -1455,9 +1457,20 @@ start_guardian_once() {
|
|
| 1455 |
}
|
| 1456 |
|
| 1457 |
while true; do
|
| 1458 |
-
|
| 1459 |
-
|
| 1460 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1461 |
fi
|
| 1462 |
|
| 1463 |
echo "Launching OpenClaw gateway on port 7860..."
|
|
|
|
| 858 |
fi
|
| 859 |
fi
|
| 860 |
|
| 861 |
+
# Pre-create runtime directory
|
| 862 |
+
mkdir -p "$JUPYTER_ROOT_DIR/.jupyter"
|
|
|
|
|
|
|
| 863 |
|
| 864 |
echo "DEV_MODE enabled (${DEV_MODE_RAW}) — starting JupyterLab terminal on internal port 8888 (path: /terminal/) with root: $JUPYTER_ROOT_DIR"
|
| 865 |
JUPYTER_LOG_FILE="/tmp/jupyterlab.log"
|
| 866 |
+
|
| 867 |
+
# Use explicit Python to avoid PATH issues; set memory-friendly limits
|
| 868 |
+
export PYTHONPATH=""
|
| 869 |
python3 -m jupyterlab \
|
| 870 |
--ip 127.0.0.1 \
|
| 871 |
--port 8888 \
|
|
|
|
| 884 |
--LabApp.check_for_updates_class=jupyterlab.NeverCheckForUpdate \
|
| 885 |
--ServerApp.quiet=True \
|
| 886 |
--ServerApp.log_level=WARNING \
|
| 887 |
+
--ServerApp.root_dir="$JUPYTER_ROOT_DIR" \
|
| 888 |
>> "$JUPYTER_LOG_FILE" 2>&1 &
|
| 889 |
JUPYTER_PID=$!
|
| 890 |
+
export JUPYTER_PID
|
| 891 |
echo "JupyterLab started (PID: $JUPYTER_PID)"
|
| 892 |
}
|
| 893 |
|
|
|
|
| 1457 |
}
|
| 1458 |
|
| 1459 |
while true; do
|
| 1460 |
+
# Check JupyterLab process - restart if died unexpectedly
|
| 1461 |
+
if [ "$RUNTIME_JUPYTER_ENABLED" = "true" ]; then
|
| 1462 |
+
if [ -n "${JUPYTER_PID:-}" ]; then
|
| 1463 |
+
if ! kill -0 "$JUPYTER_PID" 2>/dev/null; then
|
| 1464 |
+
echo "Warning: JupyterLab exited (PID $JUPYTER_PID dead); checking log..."
|
| 1465 |
+
tail -5 /tmp/jupyterlab.log 2>/dev/null || echo "No log file"
|
| 1466 |
+
echo "Attempting JupyterLab restart..."
|
| 1467 |
+
unset JUPYTER_PID
|
| 1468 |
+
start_jupyter_once
|
| 1469 |
+
fi
|
| 1470 |
+
else
|
| 1471 |
+
# First start
|
| 1472 |
+
start_jupyter_once
|
| 1473 |
+
fi
|
| 1474 |
fi
|
| 1475 |
|
| 1476 |
echo "Launching OpenClaw gateway on port 7860..."
|