feat: enable full AI automation and safe startup updates

This commit is contained in:
chenmingxuan committed 2026-09-22 23:50:03 +08:00
1 parent 2ddec53954
commit 7b1a0755e2
62 files changed
+3123 -240

No files matched your search

+14
View File
@@ -159,12 +159,19 @@ async def on_startup():
await ipc_service.start_server()
state.worker_task = asyncio.create_task(task_queue_service.queue_worker())
from apps.admin_console.services.automation_service import batch_loop
app.state.batch_worker = asyncio.create_task(batch_loop())
async def on_shutdown():
"""Stop task and IPC children before the UI server exits."""
state.is_shutting_down = True
state.shutdown_event.set()
batch_worker = getattr(app.state, "batch_worker", None)
if batch_worker:
batch_worker.cancel()
await asyncio.gather(batch_worker, return_exceptions=True)
task_queue_service._broadcast_event("server_shutdown", {"status": "stopping"})
owned_session_ids = {
str(item["session_id"])
@@ -207,6 +214,10 @@ async def on_shutdown():
for session_id in owned_session_ids:
session_repo.update_session_status(session_id, "cancelled")
from apps.admin_console.services.automation_service import background_tasks
if background_tasks:
await asyncio.gather(*list(background_tasks), return_exceptions=True)
await ipc_service.stop_server()
state.ipc_subscribers.clear()
await asyncio.to_thread(shutdown_awake_service)
@@ -224,6 +235,9 @@ app.include_router(steps.router)
app.include_router(tasks.router)
app.include_router(replay.router)
app.include_router(system.router)
from apps.admin_console.routers.automation import router as automation_router
app.include_router(automation_router)
# Mount cloud gateway router for Frappe / Cloud integration if present
try: