baseline: 批次A-D 成果 + membership 半成品(测试红)
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import os
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class CoreConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "apps.core"
|
||||
verbose_name = "核心模块"
|
||||
|
||||
def ready(self):
|
||||
"""Django 启动时即初始化 dramatiq 全局 broker。
|
||||
|
||||
关键:dramatiq 默认 get_broker() 会惰性创建"无 url 的 localhost RedisBroker",
|
||||
完全不读 REDIS_URL 环境变量。必须在任何 actor 模块被 import 之前
|
||||
加载 config.broker,把全局 broker 设为正确的 Redis 实例(或测试 StubBroker),
|
||||
否则 .send() 会连 localhost:6379 报 Connection refused。
|
||||
"""
|
||||
if os.environ.get("TASK_BROKER") == "disabled":
|
||||
return
|
||||
try:
|
||||
from config.broker import broker # noqa: F401
|
||||
except Exception:
|
||||
# broker 初始化失败不应阻断 Django 启动(如迁移/构建场景)
|
||||
pass
|
||||
Reference in New Issue
Block a user