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 asyncio
|
||||
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
|
||||
|
||||
try:
|
||||
@@ -268,6 +268,12 @@ def health():
|
||||
import sqlite3
|
||||
from search import DB_PATH
|
||||
conn = sqlite3.connect(DB_PATH)
|
||||
# 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()
|
||||
return {'status': 'ok', 'indexed': count, 'uptime': uptime}
|
||||
@@ -360,6 +366,12 @@ def brain_compose_tiers():
|
||||
|
||||
# ── 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')
|
||||
def docs_list():
|
||||
"""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)."
|
||||
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"
|
||||
if [ -f "$PIDFILE" ] && kill -0 "$(cat "$PIDFILE")" 2>/dev/null; then
|
||||
echo ""
|
||||
@@ -71,13 +85,16 @@ if [ -f "$PIDFILE" ] && kill -0 "$(cat "$PIDFILE")" 2>/dev/null; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# 6. Lancer le serveur
|
||||
# 7. Lancer le serveur
|
||||
PORT="${BRAIN_PORT:-7700}"
|
||||
LOGFILE="$BRAIN_ROOT/brain-engine/brain-engine.log"
|
||||
echo ""
|
||||
echo "=== Lancement brain-engine sur port $PORT ==="
|
||||
echo " Health : http://localhost:$PORT/health"
|
||||
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 ""
|
||||
|
||||
|
||||
@@ -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