From ab3b0b53c552e99fd1ca53e8db200fbb8ebdfd90 Mon Sep 17 00:00:00 2001 From: SITO Date: Mon, 30 Mar 2026 21:11:56 +0200 Subject: [PATCH] fix(deploy): corregir 5 problemas bloqueantes para despliegue Debian MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - install.sh/build.sh: actualizar Go 1.23 → 1.25 (requerido por rss-ingestor-go) - install.sh/build.sh: nombrar binario qdrant como qdrant_worker para coincidir con rss2-qdrant-worker.service (ExecStart) - install.sh/build.sh: GOTOOLCHAIN=local en ingestor para evitar descarga automatica de toolchain Go superior - rss2-backend.service: sobreescribir hostnames Docker (libretranslate, ollama, spacy) por 127.0.0.1 para despliegue nativo - env.example: agregar TRANSLATION_URL, OLLAMA_URL, SPACY_URL con nota explicativa sobre uso en endpoints admin - DEPLOY_DEBIAN.md: corregir comando conversion NLLB-200 a CTranslate2 usando OpusMTConverter Python API en lugar de CLI incorrecto Co-Authored-By: Claude Sonnet 4.6 --- DEPLOY_DEBIAN.md | 25 ++++++++++------------ deploy/debian/build.sh | 9 ++++++-- deploy/debian/env.example | 7 ++++++ deploy/debian/install.sh | 19 ++++++++++------ deploy/debian/systemd/rss2-backend.service | 4 ++++ 5 files changed, 41 insertions(+), 23 deletions(-) diff --git a/DEPLOY_DEBIAN.md b/DEPLOY_DEBIAN.md index 54a8784..9835f0a 100644 --- a/DEPLOY_DEBIAN.md +++ b/DEPLOY_DEBIAN.md @@ -71,25 +71,22 @@ openssl rand -hex 32 Este paso se hace **una sola vez** y puede tardar 10-30 minutos dependiendo de la conexión. ```bash -# Instalar dependencias Python primero +# Instalar dependencias Python primero (si aun no se hizo) python3 -m venv /opt/rss2/venv /opt/rss2/venv/bin/pip install ctranslate2 transformers sentencepiece -# Convertir modelo NLLB-200 a formato CTranslate2 -/opt/rss2/venv/bin/ct2-opus-mt-converter \ - --model facebook/nllb-200-distilled-600M \ - --output_dir /opt/rss2/models/nllb-ct2 \ - --quantization int8 - -# Alternativa si el comando anterior falla: -/opt/rss2/venv/bin/python -c " -import ctranslate2 -ctranslate2.converters.OpusMTConverter( - 'facebook/nllb-200-distilled-600M' -).convert('/opt/rss2/models/nllb-ct2', quantization='int8') -" +# Convertir modelo NLLB-200 a formato CTranslate2 (tarda 10-30 min) +/opt/rss2/venv/bin/python - <<'EOF' +from ctranslate2.converters import OpusMTConverter +converter = OpusMTConverter("facebook/nllb-200-distilled-600M") +converter.convert("/opt/rss2/models/nllb-ct2", quantization="int8", force=True) +print("Modelo convertido OK en /opt/rss2/models/nllb-ct2") +EOF ``` +> El modelo ocupa ~600 MB convertido. Si la descarga de HuggingFace falla, exporta +> `HF_ENDPOINT=https://huggingface.co` o usa un mirror. + ### 4. Ejecutar el instalador ```bash diff --git a/deploy/debian/build.sh b/deploy/debian/build.sh index 2699652..6dd81b2 100755 --- a/deploy/debian/build.sh +++ b/deploy/debian/build.sh @@ -22,19 +22,24 @@ if [[ -d "$REPO_ROOT/backend" ]]; then CGO_ENABLED=0 GOOS=linux go build -buildvcs=false -o "$RSS2_HOME/bin/server" ./cmd/server) info " [OK] server" - for cmd in scraper discovery wiki_worker topics related qdrant; do + for cmd in scraper discovery wiki_worker topics related; do [[ -d "$REPO_ROOT/backend/cmd/$cmd" ]] || continue (cd "$REPO_ROOT/backend" && \ CGO_ENABLED=0 GOOS=linux go build -buildvcs=false -o "$RSS2_HOME/bin/$cmd" "./cmd/$cmd") info " [OK] $cmd" done + # qdrant worker: nombre del binario debe coincidir con el service + [[ -d "$REPO_ROOT/backend/cmd/qdrant" ]] && \ + (cd "$REPO_ROOT/backend" && \ + CGO_ENABLED=0 GOOS=linux go build -buildvcs=false -o "$RSS2_HOME/bin/qdrant_worker" "./cmd/qdrant") + info " [OK] qdrant_worker" fi # --- Ingestor Go --- if [[ -d "$REPO_ROOT/rss-ingestor-go" ]]; then info "Compilando ingestor Go..." (cd "$REPO_ROOT/rss-ingestor-go" && \ - CGO_ENABLED=0 GOOS=linux go build -buildvcs=false -o "$RSS2_HOME/bin/ingestor" .) + GOTOOLCHAIN=local CGO_ENABLED=0 GOOS=linux go build -buildvcs=false -o "$RSS2_HOME/bin/ingestor" .) info " [OK] ingestor" fi diff --git a/deploy/debian/env.example b/deploy/debian/env.example index 52b91e7..406f928 100644 --- a/deploy/debian/env.example +++ b/deploy/debian/env.example @@ -34,6 +34,13 @@ TZ=Europe/Madrid # --- HuggingFace cache (modelos ML) --- HF_HOME=/opt/rss2/hf_cache +# --- Endpoints ML opcionales (solo si corres Ollama o LibreTranslate por separado) --- +# Los workers Python van directo a BD; estos endpoints solo los usa el backend para +# llamadas on-demand desde el panel admin (NER, traduccion manual, etc.) +TRANSLATION_URL=http://127.0.0.1:7790 +OLLAMA_URL=http://127.0.0.1:11434 +SPACY_URL=http://127.0.0.1:8000 + # --- Qdrant (local, sin Docker) --- QDRANT_HOST=127.0.0.1 QDRANT_PORT=6333 diff --git a/deploy/debian/install.sh b/deploy/debian/install.sh index 00da025..9627bbc 100755 --- a/deploy/debian/install.sh +++ b/deploy/debian/install.sh @@ -32,10 +32,10 @@ apt-get install -y --no-install-recommends \ ca-certificates tzdata \ libpq-dev -# Go (si no esta instalado o version < 1.22) -if ! command -v go &>/dev/null || [[ "$(go version | awk '{print $3}' | tr -d 'go')" < "1.22" ]]; then - info "Instalando Go 1.23..." - GO_VERSION="1.23.4" +# Go (rss-ingestor-go requiere Go 1.25) +if ! command -v go &>/dev/null || [[ "$(go version | awk '{print $3}' | tr -d 'go')" < "1.25" ]]; then + info "Instalando Go 1.25..." + GO_VERSION="1.25.0" ARCH=$(dpkg --print-architecture) case "$ARCH" in amd64) GO_ARCH="amd64" ;; @@ -186,18 +186,23 @@ if [[ -d "$REPO_ROOT/backend" ]]; then (cd "$REPO_ROOT/backend" && \ CGO_ENABLED=0 GOOS=linux go build -buildvcs=false -o "$RSS2_HOME/bin/server" ./cmd/server && \ info " [OK] server") || warn " [FAIL] server" - for cmd in scraper discovery wiki_worker topics related qdrant; do + for cmd in scraper discovery wiki_worker topics related; do [[ -d "$REPO_ROOT/backend/cmd/$cmd" ]] || continue (cd "$REPO_ROOT/backend" && \ CGO_ENABLED=0 GOOS=linux go build -buildvcs=false -o "$RSS2_HOME/bin/$cmd" "./cmd/$cmd" && \ info " [OK] $cmd") || warn " [FAIL] $cmd" done + # qdrant worker: output como qdrant_worker para coincidir con el service + [[ -d "$REPO_ROOT/backend/cmd/qdrant" ]] && \ + (cd "$REPO_ROOT/backend" && \ + CGO_ENABLED=0 GOOS=linux go build -buildvcs=false -o "$RSS2_HOME/bin/qdrant_worker" "./cmd/qdrant" && \ + info " [OK] qdrant_worker") || warn " [FAIL] qdrant_worker" fi -# RSS Ingestor Go (repo separado) +# RSS Ingestor Go (repo separado, requiere Go 1.25) if [[ -d "$REPO_ROOT/rss-ingestor-go" ]]; then (cd "$REPO_ROOT/rss-ingestor-go" && \ - CGO_ENABLED=0 GOOS=linux go build -buildvcs=false -o "$RSS2_HOME/bin/ingestor" . && \ + GOTOOLCHAIN=local CGO_ENABLED=0 GOOS=linux go build -buildvcs=false -o "$RSS2_HOME/bin/ingestor" . && \ info " [OK] ingestor") || warn " [FAIL] ingestor" fi diff --git a/deploy/debian/systemd/rss2-backend.service b/deploy/debian/systemd/rss2-backend.service index f50239f..3919116 100644 --- a/deploy/debian/systemd/rss2-backend.service +++ b/deploy/debian/systemd/rss2-backend.service @@ -9,6 +9,10 @@ User=rss2 Group=rss2 WorkingDirectory=/opt/rss2 EnvironmentFile=/opt/rss2/.env +# Sobreescribir hostnames Docker por localhost (los workers Python van directo a DB) +Environment=TRANSLATION_URL=http://127.0.0.1:7790 +Environment=OLLAMA_URL=http://127.0.0.1:11434 +Environment=SPACY_URL=http://127.0.0.1:8000 ExecStart=/opt/rss2/bin/server Restart=always RestartSec=5