添加了完整的 Docker 部署方案,包括: - 创建 .env.example 环境变量配置模板文件 - 新增 docker-compose.yml 用于全栈服务编排 - 为前后端分别创建 Dockerfile 实现容器化部署 - 添加 nginx.conf 配置前端反向代理 - 在 README.md 中详细说明 Docker 部署流程 - 集成 Celery 任务队列支持异步处理 - 配置多数据库服务 (MongoDB, MySQL, Redis) 的连接 - 实现健康检查和服务依赖管理
27 lines
779 B
Python
27 lines
779 B
Python
# ============================================================
|
|
# Celery 应用配置
|
|
# ============================================================
|
|
from celery import Celery
|
|
|
|
# 优先使用环境变量,否则使用默认值
|
|
import os
|
|
|
|
CELERY_BROKER_URL = os.getenv("CELERY_BROKER_URL", "redis://localhost:6379/1")
|
|
CELERY_RESULT_BACKEND = os.getenv("CELERY_RESULT_BACKEND", "redis://localhost:6379/2")
|
|
|
|
celery_app = Celery(
|
|
"filesread",
|
|
broker=CELERY_BROKER_URL,
|
|
backend=CELERY_RESULT_BACKEND,
|
|
)
|
|
|
|
celery_app.conf.update(
|
|
task_serializer="json",
|
|
accept_content=["json"],
|
|
result_serializer="json",
|
|
timezone="Asia/Shanghai",
|
|
enable_utc=True,
|
|
task_track_started=True,
|
|
task_time_limit=3600, # 1小时超时
|
|
worker_prefetch_multiplier=1,
|
|
) |