feat: Introduce bot-descarga service for PDF downloads and remote bot control. Add Docker configuration, environment variables, and a GUI for agent management. Enhance README with bot details and installation instructions.
This commit is contained in:
@@ -18,6 +18,7 @@ logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(name
|
||||
EXTRACTION_URL = os.getenv("EXTRACTION_URL", "http://extraction:8001").rstrip("/")
|
||||
CLEANING_URL = os.getenv("CLEANING_URL", "http://cleaning:8002").rstrip("/")
|
||||
COUNT_URL = os.getenv("COUNT_URL", "http://count-api:8080").rstrip("/")
|
||||
BOT_DESCARGA_URL = os.getenv("BOT_DESCARGA_URL", "http://bot-descarga:8200").rstrip("/")
|
||||
|
||||
# Timeouts: JSON ligero vs uploads OCR/conteo
|
||||
_TIMEOUT_JSON = httpx.Timeout(connect=5.0, read=30.0, write=30.0, pool=5.0)
|
||||
@@ -33,7 +34,13 @@ async def lifespan(app: FastAPI):
|
||||
timeout=_TIMEOUT_JSON,
|
||||
limits=httpx.Limits(max_connections=100, max_keepalive_connections=20),
|
||||
)
|
||||
_log.info("Gateway iniciado — extraction=%s cleaning=%s count=%s", EXTRACTION_URL, CLEANING_URL, COUNT_URL)
|
||||
_log.info(
|
||||
"Gateway iniciado — extraction=%s cleaning=%s count=%s bot_descarga=%s",
|
||||
EXTRACTION_URL,
|
||||
CLEANING_URL,
|
||||
COUNT_URL,
|
||||
BOT_DESCARGA_URL,
|
||||
)
|
||||
yield
|
||||
await _http_client.aclose()
|
||||
_http_client = None
|
||||
@@ -72,6 +79,7 @@ def _is_upload_path(path: str) -> bool:
|
||||
or "/upload" in path
|
||||
or path.startswith("/cleaning/analyze-csv")
|
||||
or path.startswith("/cleaning/jobs/from-csv")
|
||||
or path.startswith("/bot-descarga/jobs")
|
||||
)
|
||||
|
||||
|
||||
@@ -91,12 +99,14 @@ async def health() -> dict[str, Any]:
|
||||
extraction = await _safe_health(client, EXTRACTION_URL)
|
||||
cleaning = await _safe_health(client, CLEANING_URL)
|
||||
counting = await _safe_health(client, COUNT_URL)
|
||||
bot_descarga = await _safe_health(client, BOT_DESCARGA_URL)
|
||||
return {
|
||||
"status": "ok" if extraction["ok"] and cleaning["ok"] else "degraded",
|
||||
"services": {
|
||||
"extraction": extraction,
|
||||
"cleaning": cleaning,
|
||||
"counting": counting,
|
||||
"bot_descarga": bot_descarga,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -152,6 +162,11 @@ async def count_jobs_proxy(path: str, request: Request) -> Response:
|
||||
return await _proxy_request(request, f"{EXTRACTION_URL}/count-jobs/{path}")
|
||||
|
||||
|
||||
@app.api_route("/bot-descarga/{path:path}", methods=["GET", "POST", "PUT", "PATCH", "DELETE"])
|
||||
async def bot_descarga_proxy(path: str, request: Request) -> Response:
|
||||
return await _proxy_request(request, f"{BOT_DESCARGA_URL}/{path}")
|
||||
|
||||
|
||||
@app.api_route("/jobs", methods=["GET", "POST"])
|
||||
async def jobs_root_proxy(request: Request) -> Response:
|
||||
return await _proxy_request(request, f"{EXTRACTION_URL}/jobs")
|
||||
|
||||
Reference in New Issue
Block a user