Fix watcher status indicator — write status file every 5s, API reads it directly
This commit is contained in:
+12
-5
@@ -420,11 +420,12 @@ async def get_status():
|
||||
watcher_running = False
|
||||
last_indexed = "Unknown"
|
||||
try:
|
||||
result = subprocess.run(
|
||||
["systemctl", "is-active", "aaronai-watcher"],
|
||||
capture_output=True, text=True
|
||||
)
|
||||
watcher_running = result.stdout.strip() == "active"
|
||||
import time as _time, json as _json
|
||||
_sp = Path("/home/aaron/aaronai/watcher_status.json")
|
||||
if _sp.exists():
|
||||
_s = _json.loads(_sp.read_text())
|
||||
_age = _time.time() - _s.get("timestamp", 0)
|
||||
watcher_running = _s.get("running", False) and _age < 30
|
||||
except:
|
||||
pass
|
||||
|
||||
@@ -446,6 +447,12 @@ async def get_status():
|
||||
if state_path.exists():
|
||||
state = json.loads(state_path.read_text())
|
||||
file_count = len(state)
|
||||
else:
|
||||
# Count files in Nextcloud directly
|
||||
nc_path = Path(NEXTCLOUD_PATH)
|
||||
if nc_path.exists():
|
||||
file_count = sum(1 for f in nc_path.rglob("*")
|
||||
if f.is_file() and f.suffix.lower() in {'.pdf','.docx','.pptx','.txt','.md'})
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
Reference in New Issue
Block a user