Spaces:
Running
Running
fix: use venv python for JupyterLab — system python3 lacks jupyterlab
Browse filesjupyterlab is installed into /opt/hermes/.venv, not system python3.
start_jupyter() was calling python3 -c "import jupyterlab" which fails
on system python → returned 1 → set -euo pipefail killed start.sh →
container crashed every boot → HF Space stuck in RUNNING_APP_STARTING.
Fixes:
- Use /opt/hermes/.venv/bin/python for the import check and launch
- Change failing return 1s in start_jupyter to return 0 (non-fatal)
- Restore HEALTHCHECK with 60s start-period (was accidentally removed)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Dockerfile +2 -1
- start.sh +6 -5
Dockerfile
CHANGED
|
@@ -97,6 +97,7 @@ ENV HERMES_HOME=/opt/data \
|
|
| 97 |
|
| 98 |
EXPOSE 7861
|
| 99 |
|
| 100 |
-
HEALTHCHECK
|
|
|
|
| 101 |
|
| 102 |
CMD ["/opt/huggingmes/start.sh"]
|
|
|
|
| 97 |
|
| 98 |
EXPOSE 7861
|
| 99 |
|
| 100 |
+
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s \
|
| 101 |
+
CMD curl -fsS http://localhost:7861/health || exit 1
|
| 102 |
|
| 103 |
CMD ["/opt/huggingmes/start.sh"]
|
start.sh
CHANGED
|
@@ -318,18 +318,19 @@ start_jupyter() {
|
|
| 318 |
local token="${JUPYTER_TOKEN:-${API_SERVER_KEY:-}}"
|
| 319 |
if [ -z "$token" ]; then
|
| 320 |
echo "WARNING: No GATEWAY_TOKEN or JUPYTER_TOKEN set — JupyterLab skipped (terminal would be unauthenticated)." >&2
|
| 321 |
-
return
|
| 322 |
fi
|
| 323 |
export JUPYTER_TOKEN="$token"
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
|
|
|
| 327 |
fi
|
| 328 |
local root_dir="${JUPYTER_ROOT_DIR:-$HERMES_HOME/workspace}"
|
| 329 |
mkdir -p "$root_dir"
|
| 330 |
ln -sfn "$HERMES_HOME" "$root_dir/HuggingMes" 2>/dev/null || true
|
| 331 |
echo "Starting JupyterLab terminal on port 8888 (path: /terminal/) root: $root_dir"
|
| 332 |
-
|
| 333 |
--ip 127.0.0.1 \
|
| 334 |
--port 8888 \
|
| 335 |
--no-browser \
|
|
|
|
| 318 |
local token="${JUPYTER_TOKEN:-${API_SERVER_KEY:-}}"
|
| 319 |
if [ -z "$token" ]; then
|
| 320 |
echo "WARNING: No GATEWAY_TOKEN or JUPYTER_TOKEN set — JupyterLab skipped (terminal would be unauthenticated)." >&2
|
| 321 |
+
return 0
|
| 322 |
fi
|
| 323 |
export JUPYTER_TOKEN="$token"
|
| 324 |
+
local VENV_PYTHON="/opt/hermes/.venv/bin/python"
|
| 325 |
+
if ! "$VENV_PYTHON" -c "import jupyterlab" >/dev/null 2>&1; then
|
| 326 |
+
echo "WARNING: jupyterlab not installed in venv; skipping terminal." >&2
|
| 327 |
+
return 0
|
| 328 |
fi
|
| 329 |
local root_dir="${JUPYTER_ROOT_DIR:-$HERMES_HOME/workspace}"
|
| 330 |
mkdir -p "$root_dir"
|
| 331 |
ln -sfn "$HERMES_HOME" "$root_dir/HuggingMes" 2>/dev/null || true
|
| 332 |
echo "Starting JupyterLab terminal on port 8888 (path: /terminal/) root: $root_dir"
|
| 333 |
+
"$VENV_PYTHON" -m jupyterlab \
|
| 334 |
--ip 127.0.0.1 \
|
| 335 |
--port 8888 \
|
| 336 |
--no-browser \
|