INNER CODE UNIT · Python
lifespan
seapagan/fastapi-template · app/main.py:66
async def lifespan(app: FastAPI) -> AsyncGenerator[Any, None]:
"""Lifespan function Replaces the previous startup/shutdown functions.
Currently we:
- Ensure the database is available and configured properly
- Initialize the cache backend (Redis or in-memory)
"""
# Initialize loguru logging within the server process.
get_log_config()
# Validate SECRETS_DIR configuration if set.
for warning_msg in check_secrets_dir():
logger.warning(warning_msg)
loguru_logger.warning(warning_msg)
if "*" in cors_list:
warning_msg = (
"CORS_ORIGINS is set to '*', allowing any origin to access the "