Adding config endpoint
This commit is contained in:
committed by
Magel, Denis
parent
2a165c91b6
commit
579c62319c
32
src/main.py
32
src/main.py
@@ -1,30 +1,30 @@
|
||||
import os
|
||||
import json
|
||||
import logging
|
||||
import yaml
|
||||
from src.aggregate import aggregate_router
|
||||
from src.config import config_router
|
||||
|
||||
from pathlib import Path
|
||||
from dotenv import load_dotenv
|
||||
from redis import Redis
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
from pydantic import BaseModel, ValidationError, SecretStr, AnyHttpUrl
|
||||
from typing import Optional, Literal, List, Union
|
||||
from fastapi import FastAPI
|
||||
from database import setup_db_conn, get_config_from_db
|
||||
from src.initialize import initialize_config
|
||||
from utils import setup_logging
|
||||
|
||||
logger = logging.getLogger("uvicorn")
|
||||
logger.info("Starting application")
|
||||
|
||||
app = FastAPI()
|
||||
app.include_router(aggregate_router)
|
||||
app.include_router(config_router)
|
||||
|
||||
from database import setup_db_conn, get_inventory_from_redis, get_config_from_db
|
||||
from src.initialize import initialize_config
|
||||
from utils import setup_logging
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
''' make loading it async'''
|
||||
log = logging.getLogger('uvicorn')
|
||||
"""make loading it async"""
|
||||
log = logging.getLogger("uvicorn")
|
||||
cfg_init_result = initialize_config()
|
||||
|
||||
shared_redis_conn = setup_db_conn(os.getenv('redis_host'), os.getenv('redis_port'))
|
||||
|
||||
shared_redis_conn = setup_db_conn(os.getenv("redis_host"), os.getenv("redis_port"))
|
||||
if not shared_redis_conn:
|
||||
log.error("Cannot connect to Redis DB. Exiting...")
|
||||
exit(1)
|
||||
@@ -40,7 +40,7 @@ async def lifespan(app: FastAPI):
|
||||
|
||||
|
||||
setup_logging()
|
||||
log = logging.getLogger('uvicorn')
|
||||
log = logging.getLogger("uvicorn")
|
||||
|
||||
log.info("Starting FastAPI app...")
|
||||
app = FastAPI(lifespan=lifespan)
|
||||
|
||||
Reference in New Issue
Block a user