From 4bd150e32fb3d8728cea3c1de366cce8add5e343 Mon Sep 17 00:00:00 2001 From: wwwwwwwww <526125649@qq.com> Date: Wed, 17 Jun 2026 15:51:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9C=8D=E5=8A=A1=E9=A6=96?= =?UTF-8?q?=E9=A1=B5celery=E7=9B=B8=E5=85=B3=E7=9B=91=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- video-gen-api/app/main.py | 146 +++++++++++++++++++++++++++++++++++++- 1 file changed, 145 insertions(+), 1 deletion(-) 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}
+ +