mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-20 13:07:57 +09:00
feat: service health status modal with blue-green deploy details (#645)
## Summary - Clickable footer opens a modal showing all service health, versions, deploy times, and PR links - Progressive disclosure: basic info for everyone, blue-green encoder details for admins - New aggregated `/api/health/system-status` endpoint (single fetch instead of 4 separate calls) - CI captures git SHA and PR info, passes to frontend and backend builds ## Changes - **Backend**: New `/api/health/system-status` endpoint with optional admin auth for blue-green Firestore config - **Backend**: Build metadata env vars (COMMIT_SHA, PR_NUMBER, PR_TITLE, STARTUP_TIME) in version module - **Frontend**: New `SystemStatusModal` component with service cards and expandable blue-green section - **Frontend**: Footer version line is now clickable to open the modal - **Frontend**: Build metadata env vars passed through next.config.mjs - **CI**: Both frontend and backend deploy jobs capture and pass git SHA + PR info ## Testing - [x] 3 unit tests for system-status endpoint (public, offline, admin blue-green) - [x] TypeScript compilation clean (no new errors) - [x] CodeRabbit CLI reviewed @coderabbitai ignore --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
8e2a949a29
commit
9ccad7c6d3
11 files changed
+1960
-71
No files matched your search
@@ -902,6 +902,22 @@ jobs:
|
||||
# - / (main app)
|
||||
# - /app/jobs/{id}/lyrics (lyrics review)
|
||||
# - /app/jobs/{id}/instrumental (instrumental review)
|
||||
- name: Capture build metadata
|
||||
id: frontend-meta
|
||||
run: |
|
||||
echo "sha=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT
|
||||
PR_NUM=$(git log -1 --format=%s | grep -oP '\(#\K[0-9]+' | head -1 || echo "")
|
||||
if [ -n "$PR_NUM" ]; then
|
||||
PR_TITLE=$(gh pr view "$PR_NUM" --json title -q .title 2>/dev/null || echo "")
|
||||
else
|
||||
PR_NUM=""
|
||||
PR_TITLE=""
|
||||
fi
|
||||
echo "pr_number=${PR_NUM}" >> $GITHUB_OUTPUT
|
||||
echo "pr_title=${PR_TITLE}" >> $GITHUB_OUTPUT
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Install frontend dependencies
|
||||
working-directory: frontend
|
||||
run: npm ci --legacy-peer-deps
|
||||
@@ -911,6 +927,10 @@ jobs:
|
||||
working-directory: frontend
|
||||
env:
|
||||
NEXT_PUBLIC_API_URL: https://api.nomadkaraoke.com
|
||||
NEXT_PUBLIC_COMMIT_SHA: ${{ steps.frontend-meta.outputs.sha }}
|
||||
NEXT_PUBLIC_PR_NUMBER: ${{ steps.frontend-meta.outputs.pr_number }}
|
||||
NEXT_PUBLIC_PR_TITLE: ${{ steps.frontend-meta.outputs.pr_title }}
|
||||
NEXT_PUBLIC_BUILD_TIME: ${{ github.event.head_commit.timestamp }}
|
||||
run: npm run build
|
||||
|
||||
- name: Deploy consumer to Cloudflare Pages
|
||||
@@ -929,6 +949,10 @@ jobs:
|
||||
env:
|
||||
NEXT_PUBLIC_API_URL: https://api.nomadkaraoke.com
|
||||
NEXT_PUBLIC_TENANT_PORTAL: "true"
|
||||
NEXT_PUBLIC_COMMIT_SHA: ${{ steps.frontend-meta.outputs.sha }}
|
||||
NEXT_PUBLIC_PR_NUMBER: ${{ steps.frontend-meta.outputs.pr_number }}
|
||||
NEXT_PUBLIC_PR_TITLE: ${{ steps.frontend-meta.outputs.pr_title }}
|
||||
NEXT_PUBLIC_BUILD_TIME: ${{ github.event.head_commit.timestamp }}
|
||||
run: npm run build
|
||||
|
||||
- name: Deploy tenant portal to Cloudflare Pages
|
||||
@@ -1008,6 +1032,23 @@ jobs:
|
||||
echo "📋 Current version: $VERSION"
|
||||
echo "🚀 Deploying on every push to main"
|
||||
|
||||
- name: Capture build metadata
|
||||
id: build-meta
|
||||
run: |
|
||||
echo "sha=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT
|
||||
# For squash-merge commits, PR number is in the commit message as (#NNN)
|
||||
PR_NUM=$(git log -1 --format=%s | grep -oP '\(#\K[0-9]+' | head -1 || echo "")
|
||||
if [ -n "$PR_NUM" ]; then
|
||||
PR_TITLE=$(gh pr view "$PR_NUM" --json title -q .title 2>/dev/null || echo "")
|
||||
else
|
||||
PR_NUM=""
|
||||
PR_TITLE=""
|
||||
fi
|
||||
echo "pr_number=${PR_NUM}" >> $GITHUB_OUTPUT
|
||||
echo "pr_title=${PR_TITLE}" >> $GITHUB_OUTPUT
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Authenticate to Google Cloud (Workload Identity)
|
||||
id: auth
|
||||
uses: google-github-actions/auth@v2
|
||||
@@ -1569,7 +1610,7 @@ jobs:
|
||||
--min-instances 1 \
|
||||
--vpc-connector projects/nomadkaraoke/locations/us-central1/connectors/cloud-run-connector \
|
||||
--vpc-egress private-ranges-only \
|
||||
--set-env-vars "GOOGLE_CLOUD_PROJECT=${{ env.PROJECT_ID }},GCS_BUCKET_NAME=karaoke-gen-storage-${{ env.PROJECT_ID }},FIRESTORE_COLLECTION=jobs,ENVIRONMENT=production,KARAOKE_GEN_VERSION=$VERSION,DEFAULT_DROPBOX_PATH=/MediaUnsynced/Karaoke/Tracks-Organized,DEFAULT_GDRIVE_FOLDER_ID=1laRKAyxo0v817SstfM5XkpbWiNKNAMSX,ENABLE_CLOUD_TASKS=true,CLOUD_RUN_SERVICE_URL=https://api.nomadkaraoke.com,GCP_REGION=us-central1,DEFAULT_ENABLE_YOUTUBE_UPLOAD=true,DEFAULT_BRAND_PREFIX=NOMAD,DEFAULT_PRIVATE_DROPBOX_PATH=/MediaUnsynced/Karaoke/Tracks-NonPublished,DEFAULT_PRIVATE_BRAND_PREFIX=NOMADNP,USE_GCE_ENCODING=true,USE_GCE_PREVIEW_ENCODING=true,ENABLE_PUSH_NOTIFICATIONS=true,USE_CLOUD_RUN_JOBS_FOR_VIDEO=true" \
|
||||
--set-env-vars "GOOGLE_CLOUD_PROJECT=${{ env.PROJECT_ID }},GCS_BUCKET_NAME=karaoke-gen-storage-${{ env.PROJECT_ID }},FIRESTORE_COLLECTION=jobs,ENVIRONMENT=production,KARAOKE_GEN_VERSION=$VERSION,DEFAULT_DROPBOX_PATH=/MediaUnsynced/Karaoke/Tracks-Organized,DEFAULT_GDRIVE_FOLDER_ID=1laRKAyxo0v817SstfM5XkpbWiNKNAMSX,ENABLE_CLOUD_TASKS=true,CLOUD_RUN_SERVICE_URL=https://api.nomadkaraoke.com,GCP_REGION=us-central1,DEFAULT_ENABLE_YOUTUBE_UPLOAD=true,DEFAULT_BRAND_PREFIX=NOMAD,DEFAULT_PRIVATE_DROPBOX_PATH=/MediaUnsynced/Karaoke/Tracks-NonPublished,DEFAULT_PRIVATE_BRAND_PREFIX=NOMADNP,USE_GCE_ENCODING=true,USE_GCE_PREVIEW_ENCODING=true,ENABLE_PUSH_NOTIFICATIONS=true,USE_CLOUD_RUN_JOBS_FOR_VIDEO=true,COMMIT_SHA=${{ steps.build-meta.outputs.sha }},PR_NUMBER=${{ steps.build-meta.outputs.pr_number }},PR_TITLE=${{ steps.build-meta.outputs.pr_title }}" \
|
||||
--set-secrets "AUDIOSHAKE_API_TOKEN=audioshake-api-key:latest,GENIUS_API_TOKEN=genius-api-key:latest,SPOTIFY_COOKIE_SP_DC=spotify-cookie:latest,RAPIDAPI_KEY=rapidapi-key:latest,DEFAULT_DISCORD_WEBHOOK_URL=discord-releases-webhook:latest,ADMIN_TOKENS=admin-tokens:latest,RED_API_KEY=red-api-key:latest,RED_API_URL=red-api-url:latest,OPS_API_KEY=ops-api-key:latest,OPS_API_URL=ops-api-url:latest,FLACFETCH_API_URL=flacfetch-api-url:latest,FLACFETCH_API_KEY=flacfetch-api-key:latest,SENDGRID_API_KEY=sendgrid-api-key:latest,STRIPE_SECRET_KEY=stripe-secret-key:latest,STRIPE_WEBHOOK_SECRET=stripe-webhook-secret:latest,LANGFUSE_PUBLIC_KEY=langfuse-public-key:latest,LANGFUSE_SECRET_KEY=langfuse-secret-key:latest,LANGFUSE_HOST=langfuse-host:latest,ENCODING_WORKER_URL=encoding-worker-url:latest,ENCODING_WORKER_API_KEY=encoding-worker-api-key:latest,VAPID_PUBLIC_KEY=vapid-public-key:latest,VAPID_PRIVATE_KEY=vapid-private-key:latest,E2E_BYPASS_KEY=e2e-bypass-key:latest,GDRIVE_VALIDATOR_URL=gdrive-validator-url:latest"
|
||||
|
||||
- name: Update Cloud Run Jobs with new image
|
||||
|
||||
@@ -5,10 +5,12 @@ import os
|
||||
import logging
|
||||
import subprocess
|
||||
import platform
|
||||
from fastapi import APIRouter
|
||||
from typing import Dict, Any, Optional
|
||||
from fastapi import APIRouter, Depends
|
||||
from typing import Dict, Any, Optional, Tuple
|
||||
|
||||
from backend.version import VERSION
|
||||
from backend.version import VERSION, COMMIT_SHA, PR_NUMBER, PR_TITLE, STARTUP_TIME
|
||||
from backend.api.dependencies import optional_auth
|
||||
from backend.services.auth_service import UserType
|
||||
from backend.services.flacfetch_client import get_flacfetch_client
|
||||
from backend.services.email_service import get_email_service
|
||||
from backend.services.stripe_service import get_stripe_service
|
||||
@@ -308,6 +310,30 @@ async def flacfetch_health() -> Dict[str, Any]:
|
||||
}
|
||||
|
||||
|
||||
def check_audio_separator_status() -> Dict[str, Any]:
|
||||
"""Check audio separator availability without calling the remote GPU service."""
|
||||
from backend.config import get_settings
|
||||
|
||||
settings = get_settings()
|
||||
if not settings.audio_separator_api_url:
|
||||
return {
|
||||
"available": False,
|
||||
"status": "not_configured",
|
||||
}
|
||||
|
||||
try:
|
||||
from importlib.metadata import version
|
||||
pkg_version = version("audio-separator")
|
||||
except Exception:
|
||||
pkg_version = None
|
||||
|
||||
return {
|
||||
"available": True,
|
||||
"status": "ok",
|
||||
"version": pkg_version,
|
||||
}
|
||||
|
||||
|
||||
@router.get("/health/audio-separator")
|
||||
async def audio_separator_health() -> Dict[str, Any]:
|
||||
"""
|
||||
@@ -341,6 +367,118 @@ async def audio_separator_health() -> Dict[str, Any]:
|
||||
}
|
||||
|
||||
|
||||
def _get_encoding_worker_manager():
|
||||
"""Get the EncodingWorkerManager instance. Separated for testability."""
|
||||
try:
|
||||
encoding_service = get_encoding_service()
|
||||
if hasattr(encoding_service, '_worker_manager') and encoding_service._worker_manager:
|
||||
return encoding_service._worker_manager
|
||||
except Exception:
|
||||
pass
|
||||
return None
|
||||
|
||||
|
||||
@router.get("/health/system-status")
|
||||
async def system_status(
|
||||
auth: Optional[Tuple] = Depends(optional_auth),
|
||||
) -> Dict[str, Any]:
|
||||
"""
|
||||
Aggregated system status for all services.
|
||||
|
||||
Returns basic info for everyone. Admin users get additional
|
||||
blue-green deployment details for the encoder.
|
||||
"""
|
||||
is_admin = auth is not None and len(auth) >= 2 and auth[1] == UserType.ADMIN
|
||||
|
||||
# Fetch all health statuses concurrently
|
||||
import asyncio
|
||||
encoding_task = check_encoding_worker_status()
|
||||
flacfetch_task = check_flacfetch_service_status()
|
||||
encoding_status, flacfetch_status = await asyncio.gather(
|
||||
encoding_task, flacfetch_task
|
||||
)
|
||||
separator_status = check_audio_separator_status()
|
||||
|
||||
# Build frontend service info (from env vars baked at build time — returned as-is)
|
||||
frontend_svc = {
|
||||
"status": "ok",
|
||||
"version": VERSION, # Frontend and backend share the same version from pyproject.toml
|
||||
}
|
||||
|
||||
# Build backend service info
|
||||
backend_svc = {
|
||||
"status": "ok",
|
||||
"version": VERSION,
|
||||
"deployed_at": STARTUP_TIME,
|
||||
}
|
||||
if COMMIT_SHA:
|
||||
backend_svc["commit_sha"] = COMMIT_SHA
|
||||
if PR_NUMBER:
|
||||
backend_svc["pr_number"] = PR_NUMBER
|
||||
if PR_TITLE:
|
||||
backend_svc["pr_title"] = PR_TITLE
|
||||
|
||||
# Build encoder service info
|
||||
encoder_svc = {
|
||||
"status": "ok" if encoding_status.get("available") else "offline",
|
||||
"version": encoding_status.get("wheel_version"),
|
||||
"active_jobs": encoding_status.get("active_jobs", 0),
|
||||
}
|
||||
|
||||
# Build flacfetch service info
|
||||
flacfetch_svc = {
|
||||
"status": "ok" if flacfetch_status.get("available") else "offline",
|
||||
"version": flacfetch_status.get("version"),
|
||||
}
|
||||
|
||||
# Build separator service info
|
||||
separator_svc = {
|
||||
"status": "ok" if separator_status.get("available") else "offline",
|
||||
"version": separator_status.get("version"),
|
||||
}
|
||||
|
||||
# Admin-only: blue-green encoder details from Firestore
|
||||
if is_admin:
|
||||
manager = _get_encoding_worker_manager()
|
||||
if manager:
|
||||
try:
|
||||
config = manager.get_config()
|
||||
encoder_svc["admin_details"] = {
|
||||
"primary_vm": config.primary_vm,
|
||||
"primary_ip": config.primary_ip,
|
||||
"primary_version": config.primary_version,
|
||||
"primary_deployed_at": config.primary_deployed_at,
|
||||
"secondary_vm": config.secondary_vm,
|
||||
"secondary_ip": config.secondary_ip,
|
||||
"secondary_version": config.secondary_version,
|
||||
"secondary_deployed_at": config.secondary_deployed_at,
|
||||
"last_swap_at": config.last_swap_at,
|
||||
"deploy_in_progress": config.deploy_in_progress,
|
||||
"active_jobs": encoding_status.get("active_jobs", 0),
|
||||
"queue_length": encoding_status.get("queue_length", 0),
|
||||
}
|
||||
except Exception as e:
|
||||
logger.warning(f"Failed to get blue-green config: {e}")
|
||||
|
||||
# Add error details for offline services
|
||||
if not flacfetch_status.get("available"):
|
||||
flacfetch_svc["admin_details"] = {"error": flacfetch_status.get("error")}
|
||||
if not separator_status.get("available"):
|
||||
separator_svc["admin_details"] = {"error": separator_status.get("error")}
|
||||
if not encoding_status.get("available") and "admin_details" not in encoder_svc:
|
||||
encoder_svc["admin_details"] = {"error": encoding_status.get("error")}
|
||||
|
||||
return {
|
||||
"services": {
|
||||
"frontend": frontend_svc,
|
||||
"backend": backend_svc,
|
||||
"encoder": encoder_svc,
|
||||
"flacfetch": flacfetch_svc,
|
||||
"separator": separator_svc,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@router.get("/health/detailed")
|
||||
async def detailed_health_check() -> Dict[str, Any]:
|
||||
"""
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
"""Tests for the /api/health/system-status endpoint."""
|
||||
import pytest
|
||||
from unittest.mock import patch, MagicMock, AsyncMock
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_encoding_status():
|
||||
return {
|
||||
"configured": True,
|
||||
"enabled": True,
|
||||
"available": True,
|
||||
"status": "ok",
|
||||
"active_jobs": 0,
|
||||
"queue_length": 0,
|
||||
"wheel_version": "0.155.3",
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_flacfetch_status():
|
||||
return {
|
||||
"configured": True,
|
||||
"available": True,
|
||||
"status": "ok",
|
||||
"version": "0.19.1",
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_separator_status():
|
||||
return {
|
||||
"available": True,
|
||||
"status": "ok",
|
||||
"version": "0.4.3",
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_encoding_worker_config():
|
||||
"""Mock EncodingWorkerConfig dataclass."""
|
||||
config = MagicMock()
|
||||
config.primary_vm = "encoding-worker-b"
|
||||
config.primary_ip = "34.10.189.118"
|
||||
config.primary_version = "0.155.3"
|
||||
config.primary_deployed_at = "2026-03-31T18:10:00Z"
|
||||
config.secondary_vm = "encoding-worker-a"
|
||||
config.secondary_ip = "34.57.78.246"
|
||||
config.secondary_version = "0.155.2"
|
||||
config.secondary_deployed_at = "2026-03-29T14:00:00Z"
|
||||
config.last_swap_at = "2026-03-31T18:10:00Z"
|
||||
config.deploy_in_progress = False
|
||||
config.deploy_in_progress_since = None
|
||||
config.last_activity_at = None
|
||||
return config
|
||||
|
||||
|
||||
class TestSystemStatusPublic:
|
||||
"""Tests for unauthenticated /api/health/system-status."""
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_returns_all_services(
|
||||
self, mock_encoding_status, mock_flacfetch_status, mock_separator_status
|
||||
):
|
||||
from backend.api.routes.health import system_status
|
||||
|
||||
with patch("backend.api.routes.health.check_encoding_worker_status", new_callable=AsyncMock, return_value=mock_encoding_status), \
|
||||
patch("backend.api.routes.health.check_flacfetch_service_status", new_callable=AsyncMock, return_value=mock_flacfetch_status), \
|
||||
patch("backend.api.routes.health.check_audio_separator_status", return_value=mock_separator_status), \
|
||||
patch("backend.api.routes.health.VERSION", "0.155.3"), \
|
||||
patch("backend.api.routes.health.COMMIT_SHA", "8e2a949a"), \
|
||||
patch("backend.api.routes.health.PR_NUMBER", "644"), \
|
||||
patch("backend.api.routes.health.PR_TITLE", "fix: blue-green deploy"), \
|
||||
patch("backend.api.routes.health.STARTUP_TIME", "2026-03-31T18:10:00Z"):
|
||||
|
||||
result = await system_status(auth=None)
|
||||
|
||||
assert "services" in result
|
||||
services = result["services"]
|
||||
|
||||
# All 5 services present
|
||||
assert "frontend" in services
|
||||
assert "backend" in services
|
||||
assert "encoder" in services
|
||||
assert "flacfetch" in services
|
||||
assert "separator" in services
|
||||
|
||||
# Backend has build metadata
|
||||
backend_svc = services["backend"]
|
||||
assert backend_svc["version"] == "0.155.3"
|
||||
assert backend_svc["commit_sha"] == "8e2a949a"
|
||||
assert backend_svc["pr_number"] == "644"
|
||||
|
||||
# Encoder has status
|
||||
assert services["encoder"]["status"] == "ok"
|
||||
assert services["encoder"]["version"] == "0.155.3"
|
||||
|
||||
# No admin_details without auth
|
||||
assert "admin_details" not in services["encoder"]
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_offline_service(self, mock_flacfetch_status, mock_separator_status):
|
||||
from backend.api.routes.health import system_status
|
||||
|
||||
offline_encoding = {
|
||||
"configured": True,
|
||||
"enabled": True,
|
||||
"available": False,
|
||||
"error": "Connection refused",
|
||||
}
|
||||
|
||||
with patch("backend.api.routes.health.check_encoding_worker_status", new_callable=AsyncMock, return_value=offline_encoding), \
|
||||
patch("backend.api.routes.health.check_flacfetch_service_status", new_callable=AsyncMock, return_value=mock_flacfetch_status), \
|
||||
patch("backend.api.routes.health.check_audio_separator_status", return_value=mock_separator_status), \
|
||||
patch("backend.api.routes.health.VERSION", "0.155.3"), \
|
||||
patch("backend.api.routes.health.COMMIT_SHA", ""), \
|
||||
patch("backend.api.routes.health.PR_NUMBER", ""), \
|
||||
patch("backend.api.routes.health.PR_TITLE", ""), \
|
||||
patch("backend.api.routes.health.STARTUP_TIME", "2026-03-31T18:10:00Z"):
|
||||
|
||||
result = await system_status(auth=None)
|
||||
|
||||
assert result["services"]["encoder"]["status"] == "offline"
|
||||
|
||||
|
||||
class TestSystemStatusAdmin:
|
||||
"""Tests for admin-authenticated /api/health/system-status."""
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_admin_gets_bluegreen_details(
|
||||
self, mock_encoding_status, mock_flacfetch_status, mock_separator_status, mock_encoding_worker_config
|
||||
):
|
||||
from backend.api.routes.health import system_status
|
||||
from backend.services.auth_service import UserType
|
||||
|
||||
mock_auth = ("token123", UserType.ADMIN, -1)
|
||||
mock_manager = MagicMock()
|
||||
mock_manager.get_config.return_value = mock_encoding_worker_config
|
||||
|
||||
with patch("backend.api.routes.health.check_encoding_worker_status", new_callable=AsyncMock, return_value=mock_encoding_status), \
|
||||
patch("backend.api.routes.health.check_flacfetch_service_status", new_callable=AsyncMock, return_value=mock_flacfetch_status), \
|
||||
patch("backend.api.routes.health.check_audio_separator_status", return_value=mock_separator_status), \
|
||||
patch("backend.api.routes.health.VERSION", "0.155.3"), \
|
||||
patch("backend.api.routes.health.COMMIT_SHA", ""), \
|
||||
patch("backend.api.routes.health.PR_NUMBER", ""), \
|
||||
patch("backend.api.routes.health.PR_TITLE", ""), \
|
||||
patch("backend.api.routes.health.STARTUP_TIME", "2026-03-31T18:10:00Z"), \
|
||||
patch("backend.api.routes.health._get_encoding_worker_manager", return_value=mock_manager):
|
||||
|
||||
result = await system_status(auth=mock_auth)
|
||||
|
||||
encoder = result["services"]["encoder"]
|
||||
assert "admin_details" in encoder
|
||||
admin = encoder["admin_details"]
|
||||
assert admin["primary_vm"] == "encoding-worker-b"
|
||||
assert admin["secondary_vm"] == "encoding-worker-a"
|
||||
assert admin["last_swap_at"] == "2026-03-31T18:10:00Z"
|
||||
assert admin["deploy_in_progress"] is False
|
||||
@@ -25,3 +25,18 @@ def get_version() -> str:
|
||||
|
||||
|
||||
VERSION = get_version()
|
||||
|
||||
# Build metadata — set by CI during deployment
|
||||
COMMIT_SHA = os.environ.get("COMMIT_SHA", "")
|
||||
PR_NUMBER = os.environ.get("PR_NUMBER", "")
|
||||
PR_TITLE = os.environ.get("PR_TITLE", "")
|
||||
STARTUP_TIME = None # Set on first import
|
||||
|
||||
|
||||
def _get_startup_time() -> str:
|
||||
"""Record when the backend process started (proxy for deploy time)."""
|
||||
from datetime import datetime, timezone
|
||||
return datetime.now(timezone.utc).isoformat()
|
||||
|
||||
|
||||
STARTUP_TIME = _get_startup_time()
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,213 @@
|
||||
# Service Health Status Modal — Design Spec
|
||||
|
||||
## Overview
|
||||
|
||||
Replace the static footer version/status line with a clickable element that opens a modal showing detailed system status. Non-admin users see service health, versions, and deploy info. Admin users additionally see blue-green encoder deployment details. Each service links to the PR that produced its current version.
|
||||
|
||||
## Footer Changes
|
||||
|
||||
The existing footer line (`Frontend: v0.155.3 | Backend: v0.155.3 | ● Encoder: v0.155.3 | ...`) becomes a single clickable element. On hover: `cursor: pointer`, slight opacity change. No other visual changes to the footer layout.
|
||||
|
||||
Clicking anywhere on the version/status line opens the modal.
|
||||
|
||||
## Modal — Public View (everyone)
|
||||
|
||||
### Layout
|
||||
|
||||
- Standard modal: dark backdrop (click to dismiss), X close button, title "System Status"
|
||||
- Responsive card grid: 2 columns on desktop, 1 column on mobile
|
||||
- 5 service cards: **Frontend**, **Backend**, **Encoder**, **Flacfetch**, **Separator**
|
||||
|
||||
### Card Contents
|
||||
|
||||
Each card shows:
|
||||
|
||||
| Element | Example |
|
||||
|---------|---------|
|
||||
| Status indicator | Green dot (●) + "Healthy" or red dot (○) + "Offline" |
|
||||
| Version | `v0.155.3` |
|
||||
| Deploy time | "Deployed 2 hours ago" (relative) |
|
||||
| Latest change | `#644 — fix blue-green deploy` (clickable link to GitHub PR) |
|
||||
|
||||
The "Latest change" line links to the GitHub PR that produced the currently deployed version. If unavailable, this line is omitted.
|
||||
|
||||
## Modal — Admin View (additional detail)
|
||||
|
||||
When the user has an admin token (stored in localStorage from login), the modal request includes it and the response includes extra data.
|
||||
|
||||
### Encoder Blue-Green Section
|
||||
|
||||
Inside the Encoder card, below the standard info, an expandable section labeled "Blue-Green Deployment" shows:
|
||||
|
||||
- **Two side-by-side mini-cards**: Primary (green-tinted border) and Secondary (muted/grey)
|
||||
- Each mini-card shows:
|
||||
- VM name (e.g., `encoding-worker-b`)
|
||||
- Version (e.g., `v0.155.3`)
|
||||
- Role label: "PRIMARY" (green) or "SECONDARY (stopped)" (muted)
|
||||
- **Deploy status line**: "Last swap: 2 hours ago" or "⚠ Deploy in progress..." (amber)
|
||||
- **Active jobs**: count on primary, if > 0
|
||||
|
||||
### Admin Detail on Other Cards
|
||||
|
||||
For Backend, Flacfetch, and Separator cards, admin view additionally shows:
|
||||
- Error message if status is offline (from the health check error field)
|
||||
|
||||
No extra admin detail needed for Frontend (it's a static site).
|
||||
|
||||
## New Backend Endpoint
|
||||
|
||||
### `GET /api/health/system-status`
|
||||
|
||||
Single endpoint that aggregates all service health data. Avoids the current pattern of 4 separate fetches.
|
||||
|
||||
**Authentication**: Optional `X-Admin-Token` header. If valid admin token, response includes `admin_details`. If omitted or invalid, those fields are absent.
|
||||
|
||||
**Response (public fields)**:
|
||||
|
||||
```json
|
||||
{
|
||||
"services": {
|
||||
"frontend": {
|
||||
"status": "ok",
|
||||
"version": "0.155.3",
|
||||
"deployed_at": "2026-03-31T18:10:00Z",
|
||||
"commit_sha": "8e2a949a",
|
||||
"pr_number": 644,
|
||||
"pr_title": "fix: complete blue-green deploy test payload and status check"
|
||||
},
|
||||
"backend": {
|
||||
"status": "ok",
|
||||
"version": "0.155.3",
|
||||
"deployed_at": "2026-03-31T18:10:00Z",
|
||||
"commit_sha": "8e2a949a",
|
||||
"pr_number": 644,
|
||||
"pr_title": "fix: complete blue-green deploy test payload and status check"
|
||||
},
|
||||
"encoder": {
|
||||
"status": "ok",
|
||||
"version": "0.155.3",
|
||||
"deployed_at": "2026-03-31T18:10:00Z",
|
||||
"active_jobs": 0
|
||||
},
|
||||
"flacfetch": {
|
||||
"status": "ok",
|
||||
"version": "0.19.1"
|
||||
},
|
||||
"separator": {
|
||||
"status": "ok",
|
||||
"version": "0.4.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Additional fields when admin token is valid**:
|
||||
|
||||
```json
|
||||
{
|
||||
"services": {
|
||||
"encoder": {
|
||||
"admin_details": {
|
||||
"primary_vm": "encoding-worker-b",
|
||||
"primary_ip": "34.10.189.118",
|
||||
"primary_version": "0.155.3",
|
||||
"primary_deployed_at": "2026-03-31T18:10:00Z",
|
||||
"secondary_vm": "encoding-worker-a",
|
||||
"secondary_ip": "34.57.78.246",
|
||||
"secondary_version": "0.155.2",
|
||||
"secondary_deployed_at": "2026-03-29T14:00:00Z",
|
||||
"last_swap_at": "2026-03-31T18:10:00Z",
|
||||
"deploy_in_progress": false,
|
||||
"active_jobs": 0,
|
||||
"queue_length": 0
|
||||
}
|
||||
},
|
||||
"flacfetch": {
|
||||
"admin_details": {
|
||||
"error": null
|
||||
}
|
||||
},
|
||||
"separator": {
|
||||
"admin_details": {
|
||||
"error": null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Build Metadata — Git SHA and PR Info
|
||||
|
||||
Currently no git metadata is baked into builds. We need to add this.
|
||||
|
||||
### CI Changes (`.github/workflows/ci.yml`)
|
||||
|
||||
Add a step early in the deploy job that captures git info:
|
||||
|
||||
```yaml
|
||||
- name: Capture build metadata
|
||||
id: build-meta
|
||||
run: |
|
||||
echo "sha=${GITHUB_SHA::8}" >> $GITHUB_OUTPUT
|
||||
# For merge commits, extract PR number from commit message
|
||||
PR_NUM=$(git log -1 --format=%s | grep -oP '#\K[0-9]+' | head -1)
|
||||
PR_TITLE=$(gh pr view "$PR_NUM" --json title -q .title 2>/dev/null || echo "")
|
||||
echo "pr_number=${PR_NUM}" >> $GITHUB_OUTPUT
|
||||
echo "pr_title=${PR_TITLE}" >> $GITHUB_OUTPUT
|
||||
```
|
||||
|
||||
### Where metadata is stored
|
||||
|
||||
| Service | Storage mechanism |
|
||||
|---------|------------------|
|
||||
| **Frontend** | New env vars `NEXT_PUBLIC_COMMIT_SHA`, `NEXT_PUBLIC_PR_NUMBER`, `NEXT_PUBLIC_PR_TITLE`, `NEXT_PUBLIC_BUILD_TIME` set in CI before `npm run build`. Baked into the static bundle at build time via `next.config.mjs`. The `deployed_at` for frontend is the build timestamp (close enough to deploy time for Cloudflare Pages). |
|
||||
| **Backend** | New env vars `COMMIT_SHA`, `PR_NUMBER`, `PR_TITLE` set on the Cloud Run service. Read at runtime in `backend/version.py`. |
|
||||
| **Encoder** | Written to GCS version manifest alongside the existing `version.txt`. The GCE worker reads it on startup and includes in `/health` response. |
|
||||
| **Flacfetch / Separator** | These are separate repos with their own CI. PR info can be added later — for now, omit the "Latest change" line for these services. |
|
||||
|
||||
### GitHub PR Link Format
|
||||
|
||||
The frontend constructs the PR link as:
|
||||
```
|
||||
https://github.com/nomadkaraoke/karaoke-gen/pull/{pr_number}
|
||||
```
|
||||
|
||||
Displayed as: `#{pr_number} — {pr_title}` (truncated to ~60 chars if needed).
|
||||
|
||||
## Frontend Components
|
||||
|
||||
### New files
|
||||
- `frontend/components/system-status-modal.tsx` — the modal component
|
||||
|
||||
### Modified files
|
||||
- `frontend/components/version-footer.tsx` — make status line clickable, add modal toggle state
|
||||
- `frontend/lib/api.ts` — add `SystemStatus` types and `getSystemStatus()` method
|
||||
- `frontend/next.config.mjs` — pass through new `NEXT_PUBLIC_COMMIT_SHA`, `NEXT_PUBLIC_PR_NUMBER`, `NEXT_PUBLIC_PR_TITLE` env vars
|
||||
|
||||
### Modified backend files
|
||||
- `backend/api/routes/health.py` — new `/api/health/system-status` endpoint
|
||||
- `backend/version.py` — read `COMMIT_SHA`, `PR_NUMBER`, `PR_TITLE` env vars
|
||||
- `.github/workflows/ci.yml` — capture build metadata, pass to builds/deploys
|
||||
|
||||
### Data Flow
|
||||
|
||||
1. User clicks footer → modal opens, state set to loading
|
||||
2. Modal calls `GET /api/health/system-status` (with admin token header if available in localStorage)
|
||||
3. Endpoint aggregates: existing health checks + Firestore blue-green config + build metadata env vars
|
||||
4. Frontend renders cards from response
|
||||
5. No auto-refresh — data is fresh on each open
|
||||
|
||||
## Styling
|
||||
|
||||
- Follow existing project design patterns (Tailwind, CSS variables for theming)
|
||||
- Modal uses the same dark theme as the rest of the app
|
||||
- Cards use `var(--card-border)`, `var(--card-bg)` etc. for consistency
|
||||
- Green: `text-green-500` for healthy, red: `text-red-500` for offline
|
||||
- Blue-green section uses amber accent (`text-amber-500`, `border-amber-500/30`) to distinguish it as an operational detail
|
||||
|
||||
## Out of Scope
|
||||
|
||||
- Auto-refresh / polling in the modal (can be added later)
|
||||
- Flacfetch and Separator PR info (separate repos, separate CI)
|
||||
- Historical deploy data or deploy log
|
||||
- Notifications or alerts for status changes
|
||||
@@ -0,0 +1,244 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
import { api, SystemStatus, ServiceStatus } from "@/lib/api";
|
||||
|
||||
interface SystemStatusModalProps {
|
||||
open: boolean;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
function formatRelativeTime(isoString: string | null | undefined): string {
|
||||
if (!isoString) return "";
|
||||
const date = new Date(isoString);
|
||||
const now = new Date();
|
||||
const diffMs = now.getTime() - date.getTime();
|
||||
const diffMin = Math.floor(diffMs / 60000);
|
||||
if (diffMin < 1) return "just now";
|
||||
if (diffMin < 60) return `${diffMin}m ago`;
|
||||
const diffHours = Math.floor(diffMin / 60);
|
||||
if (diffHours < 24) return `${diffHours}h ago`;
|
||||
const diffDays = Math.floor(diffHours / 24);
|
||||
return `${diffDays}d ago`;
|
||||
}
|
||||
|
||||
function truncate(str: string, maxLen: number): string {
|
||||
if (str.length <= maxLen) return str;
|
||||
return str.slice(0, maxLen - 1) + "\u2026";
|
||||
}
|
||||
|
||||
function StatusDot({ status }: { status: string }) {
|
||||
const isOk = status === "ok";
|
||||
return (
|
||||
<span className={isOk ? "text-green-500" : "text-red-500"}>
|
||||
{isOk ? "\u25CF" : "\u25CB"}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function ServiceCard({
|
||||
name,
|
||||
service,
|
||||
children,
|
||||
}: {
|
||||
name: string;
|
||||
service: ServiceStatus;
|
||||
children?: React.ReactNode;
|
||||
}) {
|
||||
const isOk = service.status === "ok";
|
||||
return (
|
||||
<div
|
||||
className="rounded-lg border p-4"
|
||||
style={{
|
||||
borderColor: "var(--card-border)",
|
||||
backgroundColor: "var(--card-bg)",
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center justify-between mb-1">
|
||||
<div className="flex items-center gap-2">
|
||||
<StatusDot status={service.status} />
|
||||
<span className="font-medium text-sm">{name}</span>
|
||||
</div>
|
||||
<span className="text-xs opacity-60">
|
||||
{isOk ? "Healthy" : "Offline"}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{service.version && (
|
||||
<div className="text-xs opacity-75 mt-1">v{service.version}</div>
|
||||
)}
|
||||
|
||||
{service.deployed_at && (
|
||||
<div className="text-xs opacity-50 mt-0.5">
|
||||
Deployed {formatRelativeTime(service.deployed_at)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{service.pr_number && (
|
||||
<div className="text-xs mt-1">
|
||||
<a
|
||||
href={`https://github.com/nomadkaraoke/karaoke-gen/pull/${service.pr_number}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-amber-500 hover:underline"
|
||||
>
|
||||
#{service.pr_number}
|
||||
</a>
|
||||
{service.pr_title && (
|
||||
<span className="opacity-60">
|
||||
{" \u2014 "}
|
||||
{truncate(service.pr_title, 50)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function BlueGreenSection({ details }: { details: NonNullable<ServiceStatus["admin_details"]> }) {
|
||||
const [expanded, setExpanded] = useState(false);
|
||||
|
||||
return (
|
||||
<div className="mt-3">
|
||||
<button
|
||||
onClick={() => setExpanded(!expanded)}
|
||||
className="text-xs text-amber-500 hover:text-amber-400 flex items-center gap-1"
|
||||
>
|
||||
<span>{expanded ? "\u25BE" : "\u25B8"}</span>
|
||||
Blue-Green Deployment
|
||||
{details.deploy_in_progress && (
|
||||
<span className="text-amber-400 animate-pulse ml-1">\u26A0 deploying...</span>
|
||||
)}
|
||||
</button>
|
||||
|
||||
{expanded && (
|
||||
<div className="mt-2 grid grid-cols-2 gap-2">
|
||||
{/* Primary */}
|
||||
<div
|
||||
className="rounded p-2 text-xs border"
|
||||
style={{
|
||||
borderColor: "rgba(74,222,128,0.3)",
|
||||
backgroundColor: "rgba(74,222,128,0.05)",
|
||||
}}
|
||||
>
|
||||
<div className="text-green-500 text-[10px] font-semibold uppercase tracking-wider">
|
||||
Primary
|
||||
</div>
|
||||
<div className="mt-1 font-mono">{details.primary_vm}</div>
|
||||
<div className="opacity-60">v{details.primary_version}</div>
|
||||
{details.primary_deployed_at && (
|
||||
<div className="opacity-40">
|
||||
{formatRelativeTime(details.primary_deployed_at)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Secondary */}
|
||||
<div
|
||||
className="rounded p-2 text-xs border"
|
||||
style={{
|
||||
borderColor: "var(--card-border)",
|
||||
backgroundColor: "rgba(255,255,255,0.02)",
|
||||
}}
|
||||
>
|
||||
<div className="text-[10px] font-semibold uppercase tracking-wider opacity-50">
|
||||
Secondary (stopped)
|
||||
</div>
|
||||
<div className="mt-1 font-mono">{details.secondary_vm}</div>
|
||||
{details.secondary_version && (
|
||||
<div className="opacity-60">v{details.secondary_version}</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Metadata row */}
|
||||
<div className="col-span-2 text-[10px] opacity-40 mt-1">
|
||||
{details.last_swap_at && (
|
||||
<span>Last swap: {formatRelativeTime(details.last_swap_at)}</span>
|
||||
)}
|
||||
{details.active_jobs != null && details.active_jobs > 0 && (
|
||||
<span className="ml-3">Active jobs: {details.active_jobs}</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function SystemStatusModal({ open, onClose }: SystemStatusModalProps) {
|
||||
const [status, setStatus] = useState<SystemStatus | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
api
|
||||
.getSystemStatus()
|
||||
.then(setStatus)
|
||||
.catch((e) => setError(e.message || "Failed to fetch status"))
|
||||
.finally(() => setLoading(false));
|
||||
}, [open]);
|
||||
|
||||
const frontendVersion = process.env.NEXT_PUBLIC_APP_VERSION || "dev";
|
||||
const frontendCommitSha = process.env.NEXT_PUBLIC_COMMIT_SHA || "";
|
||||
const frontendPrNumber = process.env.NEXT_PUBLIC_PR_NUMBER || "";
|
||||
const frontendPrTitle = process.env.NEXT_PUBLIC_PR_TITLE || "";
|
||||
const frontendBuildTime = process.env.NEXT_PUBLIC_BUILD_TIME || "";
|
||||
|
||||
// Override frontend service with build-time values
|
||||
const services = status?.services;
|
||||
const frontendService: ServiceStatus = {
|
||||
status: "ok",
|
||||
version: frontendVersion,
|
||||
deployed_at: frontendBuildTime || undefined,
|
||||
commit_sha: frontendCommitSha || undefined,
|
||||
pr_number: frontendPrNumber || undefined,
|
||||
pr_title: frontendPrTitle || undefined,
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={(isOpen) => !isOpen && onClose()}>
|
||||
<DialogContent className="sm:max-w-lg" style={{ backgroundColor: "var(--card-bg)", borderColor: "var(--card-border)" }}>
|
||||
<DialogHeader>
|
||||
<DialogTitle className="text-foreground">System Status</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
{loading && (
|
||||
<div className="py-8 text-center text-sm opacity-60">Loading...</div>
|
||||
)}
|
||||
|
||||
{error && (
|
||||
<div className="py-8 text-center text-sm text-red-500">{error}</div>
|
||||
)}
|
||||
|
||||
{services && !loading && (
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-3 mt-2">
|
||||
<ServiceCard name="Frontend" service={frontendService} />
|
||||
<ServiceCard name="Backend" service={services.backend} />
|
||||
<ServiceCard name="Encoder" service={services.encoder}>
|
||||
{services.encoder.admin_details &&
|
||||
services.encoder.admin_details.primary_vm && (
|
||||
<BlueGreenSection details={services.encoder.admin_details} />
|
||||
)}
|
||||
</ServiceCard>
|
||||
<ServiceCard name="Flacfetch" service={services.flacfetch} />
|
||||
<ServiceCard name="Separator" service={services.separator} />
|
||||
</div>
|
||||
)}
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { api, EncodingWorkerHealth, FlacfetchHealth, AudioSeparatorHealth } from "@/lib/api";
|
||||
import { SystemStatusModal } from "./system-status-modal";
|
||||
|
||||
export function VersionFooter() {
|
||||
const [backendVersion, setBackendVersion] = useState<string | null>(null);
|
||||
const [encodingWorker, setEncodingWorker] = useState<EncodingWorkerHealth | null>(null);
|
||||
const [flacfetch, setFlacfetch] = useState<FlacfetchHealth | null>(null);
|
||||
const [audioSeparator, setAudioSeparator] = useState<AudioSeparatorHealth | null>(null);
|
||||
// Frontend version is injected at build time from pyproject.toml
|
||||
const [modalOpen, setModalOpen] = useState(false);
|
||||
const frontendVersion = process.env.NEXT_PUBLIC_APP_VERSION || "dev";
|
||||
|
||||
useEffect(() => {
|
||||
@@ -58,27 +59,18 @@ export function VersionFooter() {
|
||||
fetchAudioSeparatorHealth();
|
||||
}, []);
|
||||
|
||||
// Render encoding worker status indicator
|
||||
const renderEncodingWorkerStatus = () => {
|
||||
if (!encodingWorker) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (encodingWorker.status === "not_configured") {
|
||||
return null; // Don't show if not configured
|
||||
}
|
||||
if (!encodingWorker) return null;
|
||||
if (encodingWorker.status === "not_configured") return null;
|
||||
|
||||
const isHealthy = encodingWorker.available && encodingWorker.status === "ok";
|
||||
const statusColor = isHealthy ? "text-green-500" : "text-red-500";
|
||||
const statusDot = isHealthy ? "●" : "○";
|
||||
const statusDot = isHealthy ? "\u25CF" : "\u25CB";
|
||||
|
||||
// Build status text
|
||||
let statusText = isHealthy ? "Encoder" : "Encoder offline";
|
||||
if (isHealthy && encodingWorker.version) {
|
||||
statusText = `Encoder: v${encodingWorker.version}`;
|
||||
}
|
||||
|
||||
// Add active jobs indicator if there are any
|
||||
if (isHealthy && encodingWorker.active_jobs && encodingWorker.active_jobs > 0) {
|
||||
statusText += ` (${encodingWorker.active_jobs} active)`;
|
||||
}
|
||||
@@ -86,29 +78,19 @@ export function VersionFooter() {
|
||||
return (
|
||||
<>
|
||||
{" | "}
|
||||
<span className={statusColor} title={isHealthy ? "Encoding worker healthy" : encodingWorker.error || "Encoding worker offline"}>
|
||||
{statusDot}
|
||||
</span>{" "}
|
||||
{statusText}
|
||||
<span className={statusColor}>{statusDot}</span> {statusText}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
// Render flacfetch status indicator
|
||||
const renderFlacfetchStatus = () => {
|
||||
if (!flacfetch) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (flacfetch.status === "not_configured") {
|
||||
return null; // Don't show if not configured
|
||||
}
|
||||
if (!flacfetch) return null;
|
||||
if (flacfetch.status === "not_configured") return null;
|
||||
|
||||
const isHealthy = flacfetch.available && flacfetch.status === "ok";
|
||||
const statusColor = isHealthy ? "text-green-500" : "text-red-500";
|
||||
const statusDot = isHealthy ? "●" : "○";
|
||||
const statusDot = isHealthy ? "\u25CF" : "\u25CB";
|
||||
|
||||
// Build status text
|
||||
let statusText = isHealthy ? "Flacfetch" : "Flacfetch offline";
|
||||
if (isHealthy && flacfetch.version) {
|
||||
statusText = `Flacfetch: v${flacfetch.version}`;
|
||||
@@ -117,27 +99,18 @@ export function VersionFooter() {
|
||||
return (
|
||||
<>
|
||||
{" | "}
|
||||
<span className={statusColor} title={isHealthy ? "Flacfetch service healthy" : flacfetch.error || "Flacfetch service offline"}>
|
||||
{statusDot}
|
||||
</span>{" "}
|
||||
{statusText}
|
||||
<span className={statusColor}>{statusDot}</span> {statusText}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
// Render audio separator status indicator
|
||||
const renderAudioSeparatorStatus = () => {
|
||||
if (!audioSeparator) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (audioSeparator.status === "not_configured") {
|
||||
return null;
|
||||
}
|
||||
if (!audioSeparator) return null;
|
||||
if (audioSeparator.status === "not_configured") return null;
|
||||
|
||||
const isHealthy = audioSeparator.available && audioSeparator.status === "ok";
|
||||
const statusColor = isHealthy ? "text-green-500" : "text-red-500";
|
||||
const statusDot = isHealthy ? "●" : "○";
|
||||
const statusDot = isHealthy ? "\u25CF" : "\u25CB";
|
||||
|
||||
let statusText = isHealthy ? "Separator" : "Separator offline";
|
||||
if (isHealthy && audioSeparator.version) {
|
||||
@@ -147,36 +120,44 @@ export function VersionFooter() {
|
||||
return (
|
||||
<>
|
||||
{" | "}
|
||||
<span className={statusColor} title={isHealthy ? "Audio separator healthy" : audioSeparator.error || "Audio separator offline"}>
|
||||
{statusDot}
|
||||
</span>{" "}
|
||||
{statusText}
|
||||
<span className={statusColor}>{statusDot}</span> {statusText}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<footer className="border-t mt-12 py-6" style={{ borderColor: 'var(--card-border)' }}>
|
||||
<div className="px-4 text-center text-sm" style={{ color: 'var(--text-muted)' }}>
|
||||
<p>
|
||||
Powered by{" "}
|
||||
<a href="https://github.com/nomadkaraoke/karaoke-gen" className="text-amber-500 hover:underline">
|
||||
karaoke-gen
|
||||
</a>
|
||||
</p>
|
||||
<p className="mt-1 text-xs opacity-75">
|
||||
Frontend: v{frontendVersion}
|
||||
{backendVersion && (
|
||||
<>
|
||||
{" | "}
|
||||
Backend: v{backendVersion}
|
||||
</>
|
||||
)}
|
||||
{renderEncodingWorkerStatus()}
|
||||
{renderFlacfetchStatus()}
|
||||
{renderAudioSeparatorStatus()}
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
<>
|
||||
<footer className="border-t mt-12 py-6" style={{ borderColor: 'var(--card-border)' }}>
|
||||
<div className="px-4 text-center text-sm" style={{ color: 'var(--text-muted)' }}>
|
||||
<p>
|
||||
Powered by{" "}
|
||||
<a href="https://github.com/nomadkaraoke/karaoke-gen" className="text-amber-500 hover:underline">
|
||||
karaoke-gen
|
||||
</a>
|
||||
</p>
|
||||
<p
|
||||
className="mt-1 text-xs opacity-75 cursor-pointer hover:opacity-100 transition-opacity"
|
||||
onClick={() => setModalOpen(true)}
|
||||
title="Click for detailed system status"
|
||||
>
|
||||
Frontend: v{frontendVersion}
|
||||
{backendVersion && (
|
||||
<>
|
||||
{" | "}
|
||||
Backend: v{backendVersion}
|
||||
</>
|
||||
)}
|
||||
{renderEncodingWorkerStatus()}
|
||||
{renderFlacfetchStatus()}
|
||||
{renderAudioSeparatorStatus()}
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<SystemStatusModal
|
||||
open={modalOpen}
|
||||
onClose={() => setModalOpen(false)}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -304,6 +304,43 @@ export interface AudioSeparatorHealth {
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export interface ServiceStatus {
|
||||
status: string; // 'ok' | 'offline'
|
||||
version?: string | null;
|
||||
deployed_at?: string | null;
|
||||
commit_sha?: string | null;
|
||||
pr_number?: string | null;
|
||||
pr_title?: string | null;
|
||||
active_jobs?: number;
|
||||
admin_details?: {
|
||||
// Encoder blue-green
|
||||
primary_vm?: string;
|
||||
primary_ip?: string;
|
||||
primary_version?: string;
|
||||
primary_deployed_at?: string;
|
||||
secondary_vm?: string;
|
||||
secondary_ip?: string;
|
||||
secondary_version?: string;
|
||||
secondary_deployed_at?: string;
|
||||
last_swap_at?: string;
|
||||
deploy_in_progress?: boolean;
|
||||
active_jobs?: number;
|
||||
queue_length?: number;
|
||||
// Error details for offline services
|
||||
error?: string | null;
|
||||
};
|
||||
}
|
||||
|
||||
export interface SystemStatus {
|
||||
services: {
|
||||
frontend: ServiceStatus;
|
||||
backend: ServiceStatus;
|
||||
encoder: ServiceStatus;
|
||||
flacfetch: ServiceStatus;
|
||||
separator: ServiceStatus;
|
||||
};
|
||||
}
|
||||
|
||||
// Signed URL upload types
|
||||
export interface SignedUploadUrl {
|
||||
file_type: string;
|
||||
@@ -1322,6 +1359,16 @@ export const api = {
|
||||
return handleResponse(response);
|
||||
},
|
||||
|
||||
/**
|
||||
* Get aggregated system status for all services
|
||||
*/
|
||||
async getSystemStatus(): Promise<SystemStatus> {
|
||||
const response = await fetch(`${API_BASE_URL}/api/health/system-status`, {
|
||||
headers: getAuthHeaders(),
|
||||
});
|
||||
return handleResponse(response);
|
||||
},
|
||||
|
||||
// ==========================================================================
|
||||
// Credits/Payment API endpoints
|
||||
// ==========================================================================
|
||||
|
||||
@@ -20,6 +20,10 @@ try {
|
||||
const nextConfig = {
|
||||
env: {
|
||||
NEXT_PUBLIC_APP_VERSION: appVersion,
|
||||
NEXT_PUBLIC_COMMIT_SHA: process.env.NEXT_PUBLIC_COMMIT_SHA || '',
|
||||
NEXT_PUBLIC_PR_NUMBER: process.env.NEXT_PUBLIC_PR_NUMBER || '',
|
||||
NEXT_PUBLIC_PR_TITLE: process.env.NEXT_PUBLIC_PR_TITLE || '',
|
||||
NEXT_PUBLIC_BUILD_TIME: process.env.NEXT_PUBLIC_BUILD_TIME || new Date().toISOString(),
|
||||
},
|
||||
// Only use static export for production builds (not dev)
|
||||
output: process.env.NODE_ENV === 'production' ? 'export' : undefined,
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "karaoke-gen"
|
||||
version = "0.155.3"
|
||||
version = "0.156.0"
|
||||
description = "Generate karaoke videos with synchronized lyrics. Handles the entire process from downloading audio and lyrics to creating the final video with title screens."
|
||||
authors = ["Andrew Beveridge <andrew@beveridge.uk>"]
|
||||
license = "MIT"
|
||||
|
||||
Reference in new issue
Block a user