Project data management phase 1. Files can be downloaded to server and downloaded locally.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import os
|
||||
import logging
|
||||
from fastapi import FastAPI, Request, Depends
|
||||
from fastapi import FastAPI, Request, Depends, HTTPException
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from fastapi.templating import Jinja2Templates
|
||||
@@ -111,6 +111,26 @@ async def startup_event():
|
||||
await start_scheduler()
|
||||
logger.info("Scheduler service started")
|
||||
|
||||
# Sync all SLMs to SLMM on startup
|
||||
logger.info("Syncing SLM devices to SLMM...")
|
||||
try:
|
||||
from backend.services.slmm_sync import sync_all_slms_to_slmm, cleanup_orphaned_slmm_devices
|
||||
from backend.database import SessionLocal
|
||||
|
||||
db = SessionLocal()
|
||||
try:
|
||||
# Sync all SLMs from roster to SLMM
|
||||
sync_results = await sync_all_slms_to_slmm(db)
|
||||
logger.info(f"SLM sync complete: {sync_results}")
|
||||
|
||||
# Clean up orphaned devices in SLMM
|
||||
cleanup_results = await cleanup_orphaned_slmm_devices(db)
|
||||
logger.info(f"SLMM cleanup complete: {cleanup_results}")
|
||||
finally:
|
||||
db.close()
|
||||
except Exception as e:
|
||||
logger.error(f"Error syncing SLMs to SLMM on startup: {e}")
|
||||
|
||||
@app.on_event("shutdown")
|
||||
def shutdown_event():
|
||||
"""Clean up services on app shutdown"""
|
||||
|
||||
Reference in New Issue
Block a user