Inventario de proyectos

Crear un nuevo proyecto

  1. Elegir slug y puerto libre (8101–8199).
  2. Crear carpeta + venv + .env + run.py.
  3. Instalar deps y definir /health.
  4. Crear unit systemd + vhost Caddy.
  5. Smoke tests local y público.
sudo mkdir -p /srv/projects/<slug> && cd /srv/projects/<slug>
python3 -m venv venv
echo PORT=<puerto> > .env
venv/bin/pip install fastapi uvicorn gunicorn flask python-dotenv
# (pegar run.py estándar de Deploy)

Estado actual

from pathlib import Path
import json
from IPython.display import Markdown

PROJECT_ROOT = Path("/srv/projects")
STATUS_PATH = Path("/srv/projects/infra-monitor/status.json")
status_missing = False
status_map = {}

if STATUS_PATH.exists():
    status = json.loads(STATUS_PATH.read_text(encoding="utf-8"))
    status_map = {svc.get("slug"): svc for svc in status.get("services", []) if svc.get("slug")}
else:
    status_missing = True

rows = [
    "| Directorio | Monitoreado | URL | Repo | Notas |",
    "|---|:---:|---|---|---|",
]
observaciones = []

ALIAS = {
    "infra-docs": "illanes00-docs",
    "infra-docs.backup": "illanes00-docs",
}

for entry in sorted(PROJECT_ROOT.iterdir(), key=lambda p: p.name.lower()):
    if entry.name.startswith("."):
        continue
    if entry.name in {"dist", "tmp"}:
        continue
    slug = ALIAS.get(entry.name, entry.name)
    svc = status_map.get(slug)
    monitored = "🟢" if svc else ("?" if status_missing else "—")
    url = svc.get("url") if svc and svc.get("url") else "—"
    repo = svc.get("repo") if svc and svc.get("repo") else "—"
    notes = []
    if svc:
        if svc["systemd"] not in ("active", "n/a", None):
            notes.append(f"systemd={svc['systemd']}")
        if svc["http_public"] is False:
            notes.append("health público")
        if svc["http_local_caddy"] is False:
            notes.append("health Caddy")
        if svc["http_local_run"] is False:
            notes.append("run.py")
    else:
        if status_missing:
            notes.append("status.json ausente")
        else:
            notes.append("fuera de status.json")
    rows.append("| " + " | ".join([entry.name, monitored, url, repo, ", ".join(notes) or "—"]) + " |")

Markdown("\n".join(rows))

if status_missing:
    Markdown("\n> No se encontró `/srv/projects/infra-monitor/status.json`; indicadores marcados con `?`. ")

Acciones sugeridas

  • Asegurar que cada directorio tenga remoto Git (git remote -v) y health /health.
  • Añadir servicios faltantes a SERVICES dentro de infra-monitor/update_status.py.
  • Revisar los slugs marcados en “Acciones” para normalizar systemd o exposición pública.