Upgraded modules

This commit is contained in:
florian committed 2026-10-18 12:44:06 +02:00
1 parent 265015047d
commit b17963b248
2 files changed
+30 -31

No files matched your search

+6 -7
View File
@@ -15,10 +15,9 @@ from starlette.exceptions import HTTPException as StarletteHTTPException
from db_module import close_connection_pool, create_connection_pool, get_db, start_healthcheck_thread
from metrics_server import REQUEST_COUNTER
from secret_manager import cleanup_secret_files, return_credentials
from secret_manager import cleanup_secret_files, get_secret
from secret_manager.fernet_encryption import encrypt_token
from simple_logger_handler import LOG_LEVEL, setup_logger
from uvicorn_logger_config import LOGGING_CONFIG
from validator import is_valid_platform, is_valid_token, verify_api_key
logger = setup_logger(__name__)
@@ -51,7 +50,7 @@ async def lifespan(app: FastAPI):
"BACKEND_API_INTERNAL_URL",
"http://backend-api-internal.app-notifications.svc.cluster.local:8101",
)
api_key_backend_api = return_credentials("/etc/secrets/api_key")
api_key_backend_api = get_secret(os.getenv("BACKEND_API_KEY",""),"/etc/secrets/api_key")
try:
logger.info("[FastAPI] Creating MySQL connection pool...")
@@ -259,15 +258,15 @@ async def pull_notifications(
return data
async def start_servers():
logger.debug("[FastAPI] Starting servers...")
config_main = uvicorn.Config("main:api", host="0.0.0.0", port=8100, log_level=LOG_LEVEL.lower(), log_config=LOGGING_CONFIG)
config_metrics = uvicorn.Config("metrics_server:metrics_api", host="0.0.0.0", port=9000, log_level=LOG_LEVEL.lower(),log_config=LOGGING_CONFIG)
logger.info("[Server] Starting main API (port 8100) and metrics server (port 9000)...")
config_main = uvicorn.Config("main:api", host="0.0.0.0", port=8100, log_level=LOG_LEVEL.lower(), log_config=None)
config_metrics = uvicorn.Config("metrics_server:metrics_api", host="0.0.0.0", port=9000, log_level=LOG_LEVEL.lower(),log_config=None)
server_main = uvicorn.Server(config_main)
server_metrics = uvicorn.Server(config_metrics)
await asyncio.gather(server_main.serve(), server_metrics.serve())
logger.debug("[FastAPI] Servers started")
logger.info("[Server] Both servers have stopped.")
if __name__ == "__main__":
asyncio.run(start_servers())