Add DB version with alimbic and add log system
This commit is contained in:
@ -1,27 +1,54 @@
|
||||
from collections.abc import AsyncGenerator
|
||||
from contextlib import asynccontextmanager
|
||||
from mimetypes import init
|
||||
from fastapi import FastAPI, Request, HTTPException
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.middleware.gzip import GZipMiddleware
|
||||
|
||||
from fuware.core.config import get_app_settings
|
||||
from fuware import __version__
|
||||
from fuware.core.root_logger import get_logger
|
||||
from fuware.routes import router
|
||||
from fuware import __version__
|
||||
import uvicorn
|
||||
|
||||
settings = get_app_settings()
|
||||
logger = get_logger()
|
||||
|
||||
description = f"""
|
||||
fuware is a web application for managing your hours items and tracking them.
|
||||
"""
|
||||
|
||||
# event.listen(models.User.__table__, 'after_create', initialize_table)
|
||||
@asynccontextmanager
|
||||
async def lifespan_fn(_: FastAPI) -> AsyncGenerator[None, None]:
|
||||
logger.info("start: database initialization")
|
||||
import fuware.db.init_db as init_db
|
||||
|
||||
init_db.main()
|
||||
logger.info("end: database initialization")
|
||||
|
||||
logger.info("-----SYSTEM STARTUP-----")
|
||||
# logger.info("------APP SETTINGS------")
|
||||
# logger.info(
|
||||
# settings.model_dump_json(
|
||||
# indent=4,
|
||||
# exclude={
|
||||
# "SECRET",
|
||||
# "DB_URL", # replace by DB_URL_PUBLIC for logs
|
||||
# "DB_PROVIDER",
|
||||
# },
|
||||
# )
|
||||
# )
|
||||
yield
|
||||
logger.info("-----SYSTEM SHUTDOWN-----")
|
||||
|
||||
app = FastAPI(
|
||||
title="Fuware",
|
||||
description=description,
|
||||
version=__version__,
|
||||
docs_url=settings.DOCS_URL,
|
||||
redoc_url=settings.REDOC_URL
|
||||
redoc_url=settings.REDOC_URL,
|
||||
lifespan=lifespan_fn,
|
||||
)
|
||||
|
||||
app.add_middleware(GZipMiddleware, minimum_size=1000)
|
||||
|
Reference in New Issue
Block a user