mirror of
https://github.com/xpltdco/media-rip.git
synced 2026-04-03 02:53:58 -06:00
Full-featured self-hosted yt-dlp web frontend:
- Python 3.12+ / FastAPI backend with async SQLite, SSE transport, session isolation
- Vue 3 / TypeScript / Pinia frontend with real-time progress, theme picker
- 3 built-in themes (cyberpunk/dark/light) + drop-in custom theme system
- Admin auth (bcrypt), purge system, cookie upload, file serving
- Docker multi-stage build, GitHub Actions CI/CD
- 179 backend tests, 29 frontend tests (208 total)
Slices: S01 (Foundation), S02 (SSE+Sessions), S03 (Frontend),
S04 (Admin+Auth), S05 (Themes), S06 (Docker+CI)
44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
"""Health endpoint for monitoring tools and Docker healthchecks."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
from datetime import datetime, timezone
|
|
|
|
from fastapi import APIRouter, Request
|
|
|
|
from app.core.database import get_queue_depth
|
|
|
|
logger = logging.getLogger("mediarip.health")
|
|
|
|
router = APIRouter(tags=["health"])
|
|
|
|
# yt-dlp version — resolved once at import time.
|
|
# Wrapped in try/except so tests that don't install yt-dlp still work.
|
|
try:
|
|
from yt_dlp.version import __version__ as _yt_dlp_version
|
|
except ImportError: # pragma: no cover
|
|
_yt_dlp_version = "unknown"
|
|
|
|
_APP_VERSION = "0.1.0"
|
|
|
|
|
|
@router.get("/health")
|
|
async def health(request: Request) -> dict:
|
|
"""Return service health status, versions, uptime, and queue depth.
|
|
|
|
Intended consumers: Uptime Kuma, Docker HEALTHCHECK, load balancer probes.
|
|
"""
|
|
db = request.app.state.db
|
|
start_time: datetime = request.app.state.start_time
|
|
now = datetime.now(timezone.utc)
|
|
uptime = (now - start_time).total_seconds()
|
|
depth = await get_queue_depth(db)
|
|
|
|
return {
|
|
"status": "ok",
|
|
"version": _APP_VERSION,
|
|
"yt_dlp_version": _yt_dlp_version,
|
|
"uptime": uptime,
|
|
"queue_depth": depth,
|
|
}
|