diff --git a/video-gen-api/app/main.py b/video-gen-api/app/main.py index e77caf37..5c12c3a5 100644 --- a/video-gen-api/app/main.py +++ b/video-gen-api/app/main.py @@ -560,6 +560,150 @@ def create_app() -> FastAPI: async def health(): return {"status": "ok"} + @application.get("/internal/status", response_class=HTMLResponse) + async def status_page(): + from app.tasks.celery_app import celery_app + from app.config import settings + + celery_status = "unknown" + celery_error = "" + redis_status = "unknown" + redis_error = "" + + try: + if celery_app: + inspect = celery_app.control.inspect() + try: + workers = inspect.stats() + if workers: + celery_status = "running" + else: + celery_status = "no_workers" + except Exception as e: + celery_status = "error" + celery_error = str(e) + else: + celery_status = "disabled" + except Exception as e: + celery_status = "error" + celery_error = str(e) + + try: + if settings.REDIS_URL: + import redis + r = redis.from_url(settings.REDIS_URL) + r.ping() + redis_status = "connected" + else: + redis_status = "disabled" + except Exception as e: + redis_status = "disconnected" + redis_error = str(e) + + def get_celery_text(status): + if status == 'running': + return '运行中' + elif status == 'no_workers': + return '无可用 Worker' + elif status == 'disabled': + return '已禁用' + elif status == 'error': + return '连接失败' + else: + return '未知' + + def get_redis_text(status): + if status == 'connected': + return '已连接' + elif status == 'disabled': + return '已禁用' + elif status == 'disconnected': + return '未连接' + else: + return '未知' + + celery_text = get_celery_text(celery_status) + redis_text = get_redis_text(redis_status) + + celery_error_html = f'
' if celery_error else '' + redis_error_html = f'' if redis_error else '' + + html_content = f""" + + + +版本 v{settings.APP_VERSION}
+ +