auto-sync: 2026-05-17 13:48:19

This commit is contained in:
cfdaily
2026-05-17 13:48:19 +08:00
parent 4641bdcb07
commit 430fe7950e
+35 -2
View File
@@ -14,6 +14,9 @@ from fastapi.staticfiles import StaticFiles
from src.blackboard.registry import ProjectRegistry
from src.daemon.ticker import Ticker
from src.daemon.spawner import AgentSpawner
from src.daemon.dispatcher import Dispatcher
from src.daemon.counter import ActiveAgentCounter
from src.utils import get_data_root
logger = logging.getLogger("moziplus-v2")
@@ -66,14 +69,44 @@ async def lifespan(app: FastAPI):
logger.info("moziplus-v2 starting...")
registry = get_registry()
tick_interval = config.get("daemon", {}).get("tick_interval", 30)
daemon_config = config.get("daemon", {})
tick_interval = daemon_config.get("tick_interval", 30)
max_dispatch = daemon_config.get("max_dispatch_per_tick", 3)
claim_timeout = daemon_config.get("claim_timeout_minutes", 5.0)
task_timeout = daemon_config.get("default_task_timeout_minutes", 30.0)
api_host = daemon_config.get("api_host", "127.0.0.1")
api_port = daemon_config.get("api_port", 8083)
# 创建 Agent 调度组件
spawner = AgentSpawner(
dry_run=False,
agent_timeout=daemon_config.get("agent_timeout", 600),
api_host=api_host,
api_port=api_port,
)
counter = ActiveAgentCounter(
max_global=daemon_config.get("max_global_agents", 5),
max_per_agent=daemon_config.get("max_per_agent", 2),
)
registered_agents = daemon_config.get("registered_agents", [])
dispatcher = Dispatcher(
registered_agents=registered_agents,
spawner=spawner,
counter=counter,
)
ticker = Ticker(
registry=registry,
tick_interval=tick_interval,
dispatcher=dispatcher,
spawner=spawner,
max_dispatch_per_tick=max_dispatch,
claim_timeout_minutes=claim_timeout,
default_task_timeout_minutes=task_timeout,
)
await ticker.start()
logger.info("Ticker started (interval=%ss)", tick_interval)
logger.info("Ticker started (interval=%ss, dispatch=%d/tick, agents=%s)",
tick_interval, max_dispatch, registered_agents)
yield