Skip to content

Commit 64dcf11

Browse files
CopilotMte90
andcommitted
Remove FileWatcher and app_state - simplify to core functionality
Co-authored-by: Mte90 <403283+Mte90@users.noreply.github.com>
1 parent 9daeafa commit 64dcf11

File tree

7 files changed

+3
-467
lines changed

7 files changed

+3
-467
lines changed

.env.example

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,3 @@ CODING_MODEL=gpt-4o-code-preview
3030
# Host (default 127.0.0.1) and port (default 8000) used when launching uvicorn
3131
UVICORN_HOST=127.0.0.1
3232
UVICORN_PORT=8080
33-
34-
# FileWatcher configuration
35-
# Enable/disable the background file watcher that monitors project changes (default: true)
36-
FILE_WATCHER_ENABLED=true
37-
38-
# Interval in seconds between directory scans (default: 10, minimum: 5)
39-
FILE_WATCHER_INTERVAL=10
40-
41-
# Debounce time in seconds before processing detected changes (default: 5, minimum: 1)
42-
FILE_WATCHER_DEBOUNCE=5

endpoints/project_endpoints.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,6 @@ def api_create_project(request: CreateProjectRequest):
4545
"""
4646
try:
4747
project = get_or_create_project(request.path, request.name)
48-
49-
# Add project to file watcher if available
50-
try:
51-
from utils.app_state import get_file_watcher
52-
watcher = get_file_watcher()
53-
if watcher and watcher.is_running():
54-
watcher.add_project(project["id"], project["path"])
55-
except Exception as e:
56-
logger.warning(f"Could not add project to file watcher: {e}")
57-
5848
return JSONResponse(project)
5949
except ValueError as e:
6050
# ValueError is expected for invalid inputs, safe to show message

endpoints/web_endpoints.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,17 @@ def api_health():
3333
- **status**: "ok" if service is running
3434
- **version**: API version
3535
- **features**: List of enabled features
36-
- **file_watcher**: Status of the FileWatcher (if enabled)
3736
3837
Use this endpoint for:
3938
- Load balancer health checks
4039
- Monitoring systems
4140
- Service availability verification
4241
"""
43-
from utils.app_state import get_file_watcher
44-
45-
health_data = {
42+
return JSONResponse({
4643
"status": "ok",
4744
"version": "0.2.0",
48-
"features": ["rag", "per-project-db", "pycharm-api", "incremental-indexing", "rate-limiting", "caching", "file-watcher"]
49-
}
50-
51-
# Add file watcher status if available
52-
watcher = get_file_watcher()
53-
if watcher:
54-
health_data["file_watcher"] = watcher.get_status()
55-
56-
return JSONResponse(health_data)
45+
"features": ["rag", "per-project-db", "pycharm-api", "incremental-indexing", "rate-limiting", "caching"]
46+
})
5747

5848

5949
@router.get("/", response_class=HTMLResponse)

main.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,12 @@
88
import os
99
import uvicorn
1010

11-
from db import operations as db_operations
1211
from db.operations import get_or_create_project
1312
from utils.config import CFG
1413
from utils.logger import get_logger
15-
from utils import app_state
1614
from endpoints.project_endpoints import router as project_router
1715
from endpoints.query_endpoints import router as query_router
1816
from endpoints.web_endpoints import router as web_router
19-
from utils.file_watcher import FileWatcher
2017

2118
logger = 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

7637
app = FastAPI(

utils/app_state.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

utils/config.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,4 @@ def _bool_env(name, default):
3737
# uvicorn host/port (from .env)
3838
"uvicorn_host": os.getenv("UVICORN_HOST", "127.0.0.1"),
3939
"uvicorn_port": int(os.getenv("UVICORN_PORT", "8000")),
40-
41-
# FileWatcher configuration
42-
"file_watcher_enabled": _bool_env("FILE_WATCHER_ENABLED", True),
43-
"file_watcher_interval": _int_env("FILE_WATCHER_INTERVAL", 10),
44-
"file_watcher_debounce": _int_env("FILE_WATCHER_DEBOUNCE", 5),
4540
}

0 commit comments

Comments
 (0)