Lifespan context manager for startup and shutdown.
(app: FastAPI)
| 60 | |
| 61 | @asynccontextmanager |
| 62 | async def lifespan(app: FastAPI): |
| 63 | """Lifespan context manager for startup and shutdown.""" |
| 64 | # Startup - clean up orphaned lock files from previous runs |
| 65 | cleanup_orphaned_locks() |
| 66 | cleanup_orphaned_devserver_locks() |
| 67 | |
| 68 | # Start the scheduler service |
| 69 | scheduler = get_scheduler() |
| 70 | await scheduler.start() |
| 71 | |
| 72 | yield |
| 73 | |
| 74 | # Shutdown - cleanup scheduler first to stop triggering new starts |
| 75 | await cleanup_scheduler() |
| 76 | # Then cleanup all running agents, sessions, terminals, and dev servers |
| 77 | await cleanup_all_managers() |
| 78 | await cleanup_assistant_sessions() |
| 79 | await cleanup_all_expand_sessions() |
| 80 | await cleanup_all_terminals() |
| 81 | await cleanup_all_devservers() |
| 82 | |
| 83 | |
| 84 | # Create FastAPI app |
nothing calls this directly
no test coverage detected