62 lines
1.4 KiB
Python
62 lines
1.4 KiB
Python
"""
|
|
uLuforecasting Service
|
|
"""
|
|
|
|
import structlog
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.core.config import settings
|
|
from app.core.database import database_manager
|
|
from shared.monitoring.logging import setup_logging
|
|
from shared.monitoring.metrics import MetricsCollector
|
|
|
|
# Setup logging
|
|
setup_logging("forecasting-service", "INFO")
|
|
logger = structlog.get_logger()
|
|
|
|
# Create FastAPI app
|
|
app = FastAPI(
|
|
title="uLuforecasting Service",
|
|
description="uLuforecasting service for bakery forecasting",
|
|
version="1.0.0"
|
|
)
|
|
|
|
# Initialize metrics collector
|
|
metrics_collector = MetricsCollector("forecasting-service")
|
|
|
|
# CORS middleware
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
@app.on_event("startup")
|
|
async def startup_event():
|
|
"""Application startup"""
|
|
logger.info("Starting uLuforecasting Service")
|
|
|
|
# Create database tables
|
|
await database_manager.create_tables()
|
|
|
|
# Start metrics server
|
|
metrics_collector.start_metrics_server(8080)
|
|
|
|
logger.info("uLuforecasting Service started successfully")
|
|
|
|
@app.get("/health")
|
|
async def health_check():
|
|
"""Health check endpoint"""
|
|
return {
|
|
"status": "healthy",
|
|
"service": "forecasting-service",
|
|
"version": "1.0.0"
|
|
}
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
uvicorn.run(app, host="0.0.0.0", port=8000)
|