1
This commit is contained in:
+4
-3
@@ -398,7 +398,8 @@ async def _cleanup_urls(): # 实际逻辑写在 async 函数
|
|||||||
| `gen_shot_split` | 拆镜切片 | 1-2 |
|
| `gen_shot_split` | 拆镜切片 | 1-2 |
|
||||||
| `gen_api_create` | API v3 视频任务创建 | 2-4 |
|
| `gen_api_create` | API v3 视频任务创建 | 2-4 |
|
||||||
| `gen_api_poll` | API v3 视频状态轮询 | 2-4 |
|
| `gen_api_poll` | API v3 视频状态轮询 | 2-4 |
|
||||||
| `gen_api_download` | API v3 视频下载与超分 | 2-4 |
|
| `gen_api_download` | API v3 视频下载 | 2-4 |
|
||||||
|
| `gen_api_upscale` | API v3 超分 | 2-4 |
|
||||||
| `default` | 默认队列(用户 OAuth、清理任务等) | 1-2 |
|
| `default` | 默认队列(用户 OAuth、清理任务等) | 1-2 |
|
||||||
|
|
||||||
#### 完整启动命令
|
#### 完整启动命令
|
||||||
@@ -406,7 +407,7 @@ async def _cleanup_urls(): # 实际逻辑写在 async 函数
|
|||||||
```bash
|
```bash
|
||||||
# ── 单机部署(所有队列一个 Worker)──
|
# ── 单机部署(所有队列一个 Worker)──
|
||||||
celery -A app.tasks.celery_app worker -l info \
|
celery -A app.tasks.celery_app worker -l info \
|
||||||
-Q gen_chatapi_create,gen_provider_poll,gen_result_download,gen_video_upscale_local,gen_video_upscale_remote,gen_recovery,gen_private_portrait,gen_shot_analysis,gen_shot_split,gen_api_create,gen_api_poll,gen_api_download,default \
|
-Q gen_chatapi_create,gen_provider_poll,gen_result_download,gen_video_upscale_local,gen_video_upscale_remote,gen_recovery,gen_private_portrait,gen_shot_analysis,gen_shot_split,gen_api_create,gen_api_poll,gen_api_download,gen_api_upscale,default \
|
||||||
--concurrency=4
|
--concurrency=4
|
||||||
|
|
||||||
# ── 生产环境(按功能分离 Worker)──
|
# ── 生产环境(按功能分离 Worker)──
|
||||||
@@ -418,7 +419,7 @@ celery -A app.tasks.celery_app worker -l info \
|
|||||||
|
|
||||||
# 超分 Worker
|
# 超分 Worker
|
||||||
celery -A app.tasks.celery_app worker -l info \
|
celery -A app.tasks.celery_app worker -l info \
|
||||||
-Q gen_video_upscale_local,gen_video_upscale_remote \
|
-Q gen_video_upscale_local,gen_video_upscale_remote,gen_api_upscale \
|
||||||
--concurrency=2 -n worker_upscale@%h
|
--concurrency=2 -n worker_upscale@%h
|
||||||
|
|
||||||
# 恢复 Worker
|
# 恢复 Worker
|
||||||
|
|||||||
+6
-5
@@ -251,7 +251,8 @@ Celery 使用 **12 个队列**,按功能分离:
|
|||||||
| `gen_shot_split` | 拆镜切片 |
|
| `gen_shot_split` | 拆镜切片 |
|
||||||
| `gen_api_create` | **API v3 视频任务创建** |
|
| `gen_api_create` | **API v3 视频任务创建** |
|
||||||
| `gen_api_poll` | **API v3 视频状态轮询** |
|
| `gen_api_poll` | **API v3 视频状态轮询** |
|
||||||
| `gen_api_download` | **API v3 视频下载与超分** |
|
| `gen_api_download` | **API v3 视频下载** |
|
||||||
|
| `gen_api_upscale` | **API v3 超分处理(本地/远程)** |
|
||||||
| `default` | 默认队列(用户 OAuth、清理任务等) |
|
| `default` | 默认队列(用户 OAuth、清理任务等) |
|
||||||
|
|
||||||
#### 启动命令
|
#### 启动命令
|
||||||
@@ -259,7 +260,7 @@ Celery 使用 **12 个队列**,按功能分离:
|
|||||||
```bash
|
```bash
|
||||||
# ── 启动 Worker(消费所有队列,单机部署)──
|
# ── 启动 Worker(消费所有队列,单机部署)──
|
||||||
celery -A app.tasks.celery_app worker -l info \
|
celery -A app.tasks.celery_app worker -l info \
|
||||||
-Q gen_chatapi_create,gen_provider_poll,gen_result_download,gen_video_upscale_local,gen_video_upscale_remote,gen_recovery,gen_private_portrait,gen_shot_analysis,gen_shot_split,gen_api_create,gen_api_poll,gen_api_download,default \
|
-Q gen_chatapi_create,gen_provider_poll,gen_result_download,gen_video_upscale_local,gen_video_upscale_remote,gen_recovery,gen_private_portrait,gen_shot_analysis,gen_shot_split,gen_api_create,gen_api_poll,gen_api_download,gen_api_upscale,default \
|
||||||
--concurrency=4
|
--concurrency=4
|
||||||
|
|
||||||
# ── 按功能分离 Worker(生产环境推荐)──
|
# ── 按功能分离 Worker(生产环境推荐)──
|
||||||
@@ -270,9 +271,9 @@ celery -A app.tasks.celery_app worker -l info \
|
|||||||
--concurrency=4 \
|
--concurrency=4 \
|
||||||
-n worker_busy@%h
|
-n worker_busy@%h
|
||||||
|
|
||||||
# 超分 Worker:处理本地和远程超分
|
# 超分 Worker:处理本地和远程超分(含 API v3 超分)
|
||||||
celery -A app.tasks.celery_app worker -l info \
|
celery -A app.tasks.celery_app worker -l info \
|
||||||
-Q gen_video_upscale_local,gen_video_upscale_remote \
|
-Q gen_video_upscale_local,gen_video_upscale_remote,gen_api_upscale \
|
||||||
--concurrency=2 \
|
--concurrency=2 \
|
||||||
-n worker_upscale@%h
|
-n worker_upscale@%h
|
||||||
|
|
||||||
@@ -326,7 +327,7 @@ Type=simple
|
|||||||
User=www-data
|
User=www-data
|
||||||
WorkingDirectory=/opt/video-gen-api
|
WorkingDirectory=/opt/video-gen-api
|
||||||
Environment=PATH=/opt/video-gen-api/.venv/bin
|
Environment=PATH=/opt/video-gen-api/.venv/bin
|
||||||
ExecStart=/opt/video-gen-api/.venv/bin/celery -A app.tasks.celery_app worker -l info -Q gen_video_upscale_local,gen_video_upscale_remote --concurrency=2 -n worker_upscale@%h
|
ExecStart=/opt/video-gen-api/.venv/bin/celery -A app.tasks.celery_app worker -l info -Q gen_video_upscale_local,gen_video_upscale_remote,gen_api_upscale --concurrency=2 -n worker_upscale@%h
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=5
|
RestartSec=5
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ class CeleryQueue(str, Enum):
|
|||||||
GEN_PRIVATE_PORTRAIT = "gen_private_portrait"
|
GEN_PRIVATE_PORTRAIT = "gen_private_portrait"
|
||||||
GEN_SHOT_ANALYSIS = "gen_shot_analysis"
|
GEN_SHOT_ANALYSIS = "gen_shot_analysis"
|
||||||
GEN_SHOT_SPLIT = "gen_shot_split"
|
GEN_SHOT_SPLIT = "gen_shot_split"
|
||||||
|
GEN_API_UPSCALE = "gen_api_upscale"
|
||||||
DEFAULT = "default"
|
DEFAULT = "default"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -532,9 +532,9 @@ async def _download_generation_result(self, task_id: str) -> dict[str, Any]:
|
|||||||
from app.services.video_upscale.media_service import probe_video
|
from app.services.video_upscale.media_service import probe_video
|
||||||
source_info = await probe_video(abs_path)
|
source_info = await probe_video(abs_path)
|
||||||
if source_info:
|
if source_info:
|
||||||
task.source_width = source_info.width
|
source_width = source_info.width
|
||||||
task.source_height = source_info.height
|
source_height = source_info.height
|
||||||
task.source_duration_seconds = round(source_info.duration_seconds, 2)
|
source_duration = round(source_info.duration_seconds, 2)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.warning("Failed to probe video info: %s", exc)
|
logger.warning("Failed to probe video info: %s", exc)
|
||||||
|
|
||||||
@@ -546,6 +546,9 @@ async def _download_generation_result(self, task_id: str) -> dict[str, Any]:
|
|||||||
db=db,
|
db=db,
|
||||||
api_task=task,
|
api_task=task,
|
||||||
source_local_path=dest_path,
|
source_local_path=dest_path,
|
||||||
|
source_width=source_width,
|
||||||
|
source_height=source_height,
|
||||||
|
source_duration=source_duration,
|
||||||
)
|
)
|
||||||
|
|
||||||
# 如果已存在超分任务(重复调用),检查超分状态
|
# 如果已存在超分任务(重复调用),检查超分状态
|
||||||
@@ -585,13 +588,13 @@ async def _download_generation_result(self, task_id: str) -> dict[str, Any]:
|
|||||||
if processor_key in ("local_ffmpeg_crop_v1",):
|
if processor_key in ("local_ffmpeg_crop_v1",):
|
||||||
api_upscale_execute_local_simple.apply_async(
|
api_upscale_execute_local_simple.apply_async(
|
||||||
args=[upscale_task.id],
|
args=[upscale_task.id],
|
||||||
queue="gen_api_upscale",
|
queue=CeleryQueue.GEN_API_UPSCALE.value,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# 远程超分(火山 MediaKit)
|
# 远程超分(火山 MediaKit)
|
||||||
api_upscale_submit_remote_simple.apply_async(
|
api_upscale_submit_remote_simple.apply_async(
|
||||||
args=[upscale_task.id],
|
args=[upscale_task.id],
|
||||||
queue="gen_api_upscale",
|
queue=CeleryQueue.GEN_API_UPSCALE.value,
|
||||||
)
|
)
|
||||||
await db.commit()
|
await db.commit()
|
||||||
|
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ def api_upscale_submit_remote_simple(self, upscale_task_id: str) -> dict[str, An
|
|||||||
api_upscale_poll_remote_simple.apply_async(
|
api_upscale_poll_remote_simple.apply_async(
|
||||||
args=[upscale_task_id],
|
args=[upscale_task_id],
|
||||||
countdown=30,
|
countdown=30,
|
||||||
queue="gen_api_upscale",
|
queue=CeleryQueue.GEN_API_UPSCALE.value,
|
||||||
)
|
)
|
||||||
|
|
||||||
return {"status": "submitted", "provider_task_id": submit_result.task_id}
|
return {"status": "submitted", "provider_task_id": submit_result.task_id}
|
||||||
@@ -350,7 +350,7 @@ def api_upscale_poll_remote_simple(self, upscale_task_id: str) -> dict[str, Any]
|
|||||||
api_upscale_poll_remote_simple.apply_async(
|
api_upscale_poll_remote_simple.apply_async(
|
||||||
args=[upscale_task_id],
|
args=[upscale_task_id],
|
||||||
countdown=30,
|
countdown=30,
|
||||||
queue="gen_api_upscale",
|
queue=CeleryQueue.GEN_API_UPSCALE.value,
|
||||||
)
|
)
|
||||||
return {"status": "polling"}
|
return {"status": "polling"}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ services:
|
|||||||
|
|
||||||
worker:
|
worker:
|
||||||
build: .
|
build: .
|
||||||
command: celery -A app.tasks.celery_app worker -l info
|
command: celery -A app.tasks.celery_app worker -l info -Q default,gen_chatapi_create,gen_provider_poll,gen_result_download,gen_recovery,gen_video_upscale_local,gen_video_upscale_remote,gen_private_portrait,gen_shot_analysis,gen_shot_split,gen_api_upscale
|
||||||
volumes:
|
volumes:
|
||||||
- .:/app
|
- .:/app
|
||||||
env_file:
|
env_file:
|
||||||
|
|||||||
Reference in New Issue
Block a user