fixing mail
This commit is contained in:
22
main.py
22
main.py
@@ -21,12 +21,29 @@ from app.routes.users import router as users_router
|
||||
from app.routes.offices import router as offices_router
|
||||
from app.routes.presence import router as presence_router
|
||||
from app.routes.parking import router as parking_router
|
||||
from database.connection import init_db
|
||||
from app.routes.parking import router as parking_router
|
||||
from database.connection import init_db, get_db_session
|
||||
from services.notifications import run_scheduled_notifications
|
||||
import asyncio
|
||||
|
||||
# Rate limiter setup
|
||||
limiter = Limiter(key_func=get_remote_address)
|
||||
|
||||
|
||||
async def scheduler_task():
|
||||
"""Background task to run scheduled notifications every minute"""
|
||||
config.logger.info("Scheduler task started")
|
||||
while True:
|
||||
try:
|
||||
with get_db_session() as db:
|
||||
run_scheduled_notifications(db)
|
||||
except Exception as e:
|
||||
config.logger.error(f"Scheduler error: {e}")
|
||||
|
||||
# Check every 60 seconds
|
||||
await asyncio.sleep(60)
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
"""Initialize database on startup"""
|
||||
@@ -72,6 +89,9 @@ async def lifespan(app: FastAPI):
|
||||
|
||||
log(f"feedback: App reachable via Caddy at {reachable_url}")
|
||||
|
||||
# Start scheduler
|
||||
asyncio.create_task(scheduler_task())
|
||||
|
||||
yield
|
||||
log("Shutting down Parking Manager application")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user