88import os
99import uvicorn
1010
11- from db import operations as db_operations
1211from db .operations import get_or_create_project
1312from utils .config import CFG
1413from utils .logger import get_logger
15- from utils import app_state
1614from endpoints .project_endpoints import router as project_router
1715from endpoints .query_endpoints import router as query_router
1816from endpoints .web_endpoints import router as web_router
19- from utils .file_watcher import FileWatcher
2017
2118logger = get_logger (__name__ )
2219
@@ -34,43 +31,7 @@ async def lifespan(app: FastAPI):
3431 except Exception as e :
3532 logger .warning (f"Could not create default project: { e } " )
3633
37- # Start FileWatcher if enabled
38- if CFG .get ("file_watcher_enabled" , True ):
39- try :
40- watcher = FileWatcher (
41- logger = logger ,
42- enabled = True ,
43- debounce_seconds = CFG .get ("file_watcher_debounce" , 5 ),
44- check_interval = CFG .get ("file_watcher_interval" , 10 )
45- )
46-
47- # Add all existing projects to the watcher
48- try :
49- projects = db_operations .list_projects ()
50- for project in projects :
51- if project .get ("path" ) and os .path .exists (project ["path" ]):
52- watcher .add_project (project ["id" ], project ["path" ])
53- except Exception as e :
54- logger .warning (f"Could not add projects to file watcher: { e } " )
55-
56- watcher .start ()
57- app_state .set_file_watcher (watcher )
58- logger .info ("FileWatcher started successfully" )
59- except Exception as e :
60- logger .error (f"Failed to start FileWatcher: { e } " )
61- else :
62- logger .info ("FileWatcher is disabled in configuration" )
63-
6434 yield
65-
66- # Stop FileWatcher on shutdown
67- shutdown_watcher = app_state .get_file_watcher ()
68- if shutdown_watcher :
69- try :
70- shutdown_watcher .stop ()
71- logger .info ("FileWatcher stopped successfully" )
72- except Exception as e :
73- logger .error (f"Error stopping FileWatcher: { e } " )
7435
7536
7637app = FastAPI (
0 commit comments