MCPcopy Create free account
hub / github.com/AutoForgeAI/autoforge / lifespan

Function lifespan

server/main.py:62–81  ·  view source on GitHub ↗

Lifespan context manager for startup and shutdown.

(app: FastAPI)

Source from the content-addressed store, hash-verified

60
61@asynccontextmanager
62async 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

Callers

nothing calls this directly

Calls 9

cleanup_orphaned_locksFunction · 0.85
get_schedulerFunction · 0.85
cleanup_schedulerFunction · 0.85
cleanup_all_managersFunction · 0.85
cleanup_all_terminalsFunction · 0.85
cleanup_all_devserversFunction · 0.85
startMethod · 0.45

Tested by

no test coverage detected