INNER CODE UNIT · Python
lifespan
BlessedRebuS/Krawl · src/app.py:51
async def lifespan(app: FastAPI):
"""Application startup and shutdown lifecycle."""
gc.set_threshold(700, 10, 5)
config = get_config()
# Initialize logging
initialize_logging(log_level=config.log_level)
app_logger = get_app_logger()
# Initialize database and run pending migrations before accepting traffic
try:
if config.mode == "scalable":
app_logger.info("Initializing database in scalable mode (PostgreSQL)")
initialize_database(
database_path=config.database_path,
mode="scalable",
postgres_config={