MCPcopy Index your code
hub / github.com/TaskingAI/TaskingAI / lifespan

Function lifespan

backend/app/fastapi_app.py:31–53  ·  view source on GitHub ↗
(app: FastAPI)

Source from the content-addressed store, hash-verified

29
30@asynccontextmanager
31async def lifespan(app: FastAPI):
32 from app.database import close_database, init_database
33 from app.services.auth.admin import create_default_admin_if_needed
34 from app.config import CONFIG
35
36 try:
37 logger.info("fastapi app startup...")
38
39 logger.info("start plugin cache scheduler...")
40 _scheduler.add_job(sync_data, "interval", minutes=1)
41 _scheduler.start()
42 # first sync
43 await sync_data(first_sync=True)
44
45 await init_database()
46 if CONFIG.WEB:
47 await create_default_admin_if_needed()
48
49 yield
50
51 finally:
52 logger.info("fastapi app shutdown...")
53 await close_database()
54
55
56def create_app():

Callers

nothing calls this directly

Calls 4

init_databaseFunction · 0.90
close_databaseFunction · 0.90
sync_dataFunction · 0.85

Tested by

no test coverage detected