refactor(runtime): decouple scheduler tasks and align worker group names

This commit is contained in:
qzl
2026-03-20 14:06:37 +08:00
parent fbf15bc937
commit 19a2cd451d
9 changed files with 97 additions and 80 deletions
+22 -8
View File
@@ -5,7 +5,10 @@ import subprocess
import sys
from pathlib import Path
from core.agentscope.runtime.tasks import run_automation_scheduler_scan
from apscheduler.schedulers.blocking import BlockingScheduler
from apscheduler.triggers.interval import IntervalTrigger
from core.automation.scheduler import run_automation_scheduler_scan
from core.config.settings import config
from core.config.initial.init_data import initialize_data
from core.logging import get_logger
@@ -103,24 +106,34 @@ async def bootstrap() -> bool:
return True
async def run_automation_scheduler_forever() -> bool:
async def run_automation_scheduler_forever() -> None:
if not config.automation_scheduler.enabled:
logger.info("Automation scheduler disabled by config")
return True
return
interval_seconds = int(config.automation_scheduler.interval_seconds)
batch_limit = int(config.automation_scheduler.batch_limit)
logger.info(
"Starting automation scheduler loop",
"Starting automation scheduler",
interval_seconds=interval_seconds,
batch_limit=batch_limit,
)
while True:
def scan_job() -> None:
try:
await run_automation_scheduler_scan(limit=batch_limit)
asyncio.run(run_automation_scheduler_scan(limit=batch_limit))
except Exception as exc:
logger.exception("Automation scheduler scan failed", error=str(exc))
await asyncio.sleep(interval_seconds)
scheduler = BlockingScheduler()
scheduler.add_job(
scan_job,
trigger=IntervalTrigger(seconds=interval_seconds),
id="automation_scheduler_scan",
name="Automation scheduler scan",
replace_existing=True,
)
scheduler.start()
def main() -> int:
@@ -142,7 +155,8 @@ def main() -> int:
elif command == "bootstrap":
success = asyncio.run(bootstrap())
elif command == "automation-scheduler":
success = asyncio.run(run_automation_scheduler_forever())
asyncio.run(run_automation_scheduler_forever())
return 0
else:
logger.error("Unknown command", command=command)
logger.info(