INNER CODE UNIT · Python
startup_event
agentscope-ai/agentscope-runtime · src/agentscope_runtime/sandbox/manager/server/app.py:210
async def startup_event():
"""Initialize the SandboxManager on startup"""
get_sandbox_manager()
register_routes(app, _sandbox_manager)
# Start heartbeat watcher on server side
_sandbox_manager.start_watcher()
@app.on_event("shutdown")
async def shutdown_event():
"""Cleanup resources on shutdown"""
global _sandbox_manager
settings = get_settings()
if not _sandbox_manager:
return
# stop watcher first