fix: start.sh auto-build brain-ui + /health tolerant sans Ollama + docs source unique brain-engine
- start.sh: detecte brain-ui/dist absent → build auto si Node dispo, warning sinon - start.sh: lien docs pointe vers /ui/docs (page rendue) au lieu de /docs (JSON) - server.py /health: tolere absence table embeddings (pas d'Ollama = indexed:0, pas crash) - server.py /docs/view: redirect 302 → /ui/docs pour navigateurs - public/docs/ supprime: source unique = docs/ servi par brain-engine API
This commit is contained in:
@@ -67,7 +67,7 @@ from pathlib import Path
|
|||||||
import subprocess
|
import subprocess
|
||||||
import asyncio
|
import asyncio
|
||||||
from fastapi import FastAPI, Header, HTTPException, Query, Body, WebSocket, Request
|
from fastapi import FastAPI, Header, HTTPException, Query, Body, WebSocket, Request
|
||||||
from fastapi.responses import JSONResponse
|
from fastapi.responses import JSONResponse, RedirectResponse
|
||||||
from fastapi.websockets import WebSocketDisconnect
|
from fastapi.websockets import WebSocketDisconnect
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -268,7 +268,13 @@ def health():
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
from search import DB_PATH
|
from search import DB_PATH
|
||||||
conn = sqlite3.connect(DB_PATH)
|
conn = sqlite3.connect(DB_PATH)
|
||||||
count = conn.execute("SELECT COUNT(*) FROM embeddings WHERE indexed=1").fetchone()[0]
|
# embeddings table is created by embed.py (requires Ollama) — optional
|
||||||
|
has_embeddings = conn.execute(
|
||||||
|
"SELECT name FROM sqlite_master WHERE type='table' AND name='embeddings'"
|
||||||
|
).fetchone()
|
||||||
|
count = 0
|
||||||
|
if has_embeddings:
|
||||||
|
count = conn.execute("SELECT COUNT(*) FROM embeddings WHERE indexed=1").fetchone()[0]
|
||||||
conn.close()
|
conn.close()
|
||||||
return {'status': 'ok', 'indexed': count, 'uptime': uptime}
|
return {'status': 'ok', 'indexed': count, 'uptime': uptime}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -360,6 +366,12 @@ def brain_compose_tiers():
|
|||||||
|
|
||||||
# ── Docs live — sert docs/*.md depuis le filesystem ────────────────────────────
|
# ── Docs live — sert docs/*.md depuis le filesystem ────────────────────────────
|
||||||
|
|
||||||
|
@app.get('/docs/view')
|
||||||
|
def docs_redirect():
|
||||||
|
"""Redirige /docs/view vers le dashboard docs (pour les navigateurs)."""
|
||||||
|
return RedirectResponse(url='/ui/docs', status_code=302)
|
||||||
|
|
||||||
|
|
||||||
@app.get('/docs')
|
@app.get('/docs')
|
||||||
def docs_list():
|
def docs_list():
|
||||||
"""Liste les fichiers docs/*.md avec métadonnées (frontmatter group/label)."""
|
"""Liste les fichiers docs/*.md avec métadonnées (frontmatter group/label)."""
|
||||||
|
|||||||
@@ -61,7 +61,21 @@ else
|
|||||||
echo " Le serveur démarre quand même (BSI, docs, endpoints basiques)."
|
echo " Le serveur démarre quand même (BSI, docs, endpoints basiques)."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 5. Vérifier si déjà en cours
|
# 5. Vérifier brain-ui (dashboard + docs)
|
||||||
|
UI_DIST="$BRAIN_ROOT/brain-ui/dist"
|
||||||
|
if [ ! -d "$UI_DIST" ]; then
|
||||||
|
echo ""
|
||||||
|
echo "⚠️ brain-ui pas buildé — le dashboard ne sera pas disponible."
|
||||||
|
if command -v node &>/dev/null && command -v npm &>/dev/null; then
|
||||||
|
echo "→ Build automatique de brain-ui..."
|
||||||
|
bash "$BRAIN_ROOT/brain-ui/build.sh"
|
||||||
|
else
|
||||||
|
echo " Node.js/npm requis pour le dashboard."
|
||||||
|
echo " Installe Node.js 18+ puis lance : bash brain-ui/build.sh"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 6. Vérifier si déjà en cours (re-check après build éventuel)
|
||||||
PIDFILE="$BRAIN_ROOT/.brain-engine.pid"
|
PIDFILE="$BRAIN_ROOT/.brain-engine.pid"
|
||||||
if [ -f "$PIDFILE" ] && kill -0 "$(cat "$PIDFILE")" 2>/dev/null; then
|
if [ -f "$PIDFILE" ] && kill -0 "$(cat "$PIDFILE")" 2>/dev/null; then
|
||||||
echo ""
|
echo ""
|
||||||
@@ -71,13 +85,16 @@ if [ -f "$PIDFILE" ] && kill -0 "$(cat "$PIDFILE")" 2>/dev/null; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 6. Lancer le serveur
|
# 7. Lancer le serveur
|
||||||
PORT="${BRAIN_PORT:-7700}"
|
PORT="${BRAIN_PORT:-7700}"
|
||||||
LOGFILE="$BRAIN_ROOT/brain-engine/brain-engine.log"
|
LOGFILE="$BRAIN_ROOT/brain-engine/brain-engine.log"
|
||||||
echo ""
|
echo ""
|
||||||
echo "=== Lancement brain-engine sur port $PORT ==="
|
echo "=== Lancement brain-engine sur port $PORT ==="
|
||||||
echo " Health : http://localhost:$PORT/health"
|
echo " Health : http://localhost:$PORT/health"
|
||||||
echo " Dashboard : http://localhost:$PORT/ui/"
|
if [ -d "$UI_DIST" ]; then
|
||||||
|
echo " Dashboard : http://localhost:$PORT/ui/"
|
||||||
|
fi
|
||||||
|
echo " Docs : http://localhost:$PORT/ui/docs"
|
||||||
echo " Agents : http://localhost:$PORT/agents"
|
echo " Agents : http://localhost:$PORT/agents"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
../../../docs/README.md
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../../docs/agents-brain.md
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../../docs/agents-code.md
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../../docs/agents-infra.md
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../../docs/agents.md
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../../docs/architecture.md
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../../docs/brain-engine-guide.md
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../../docs/getting-started.md
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../../docs/satellites.md
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../../docs/sessions.md
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../../docs/vue-featured.md
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../../docs/vue-free.md
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../../docs/vue-full.md
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../../docs/vue-pro.md
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../../docs/vue-tiers.md
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
../../../docs/workflows.md
|
|
||||||
Reference in New Issue
Block a user