Fix watcher status indicator — write status file every 5s, API reads it directly
This commit is contained in:
@@ -14,6 +14,7 @@ STATE_FILE = "/home/aaron/aaronai/watcher_state.json"
|
||||
|
||||
SUPPORTED = {'.pdf', '.docx', '.pptx', '.txt', '.md'}
|
||||
DEBOUNCE_SECONDS = 120
|
||||
STATUS_FILE = "/home/aaron/aaronai/watcher_status.json"
|
||||
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
@@ -109,6 +110,13 @@ def main():
|
||||
|
||||
try:
|
||||
while True:
|
||||
import json as _json
|
||||
_json.dump({
|
||||
"running": True,
|
||||
"timestamp": time.time(),
|
||||
"pending": handler.pending,
|
||||
"last_event": handler.last_event
|
||||
}, open(STATUS_FILE, 'w'))
|
||||
if handler.pending:
|
||||
elapsed = time.time() - handler.last_event
|
||||
if elapsed >= DEBOUNCE_SECONDS:
|
||||
|
||||
Reference in New Issue
Block a user