From bc4405239105ce5bdf616cfb6a2300c74692eeb7 Mon Sep 17 00:00:00 2001 From: igor04091968 Date: Wed, 13 May 2026 02:35:59 +0300 Subject: [PATCH] fix(health): treat stale file-operations buckets as warning by default --- aw-server/health-check.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/aw-server/health-check.sh b/aw-server/health-check.sh index e839b79..38bfa43 100644 --- a/aw-server/health-check.sh +++ b/aw-server/health-check.sh @@ -42,6 +42,7 @@ check_api_endpoint() { check_dlp_transport_freshness() { local api_base="${1:-http://127.0.0.1:5600/api/0}" local max_age_seconds="${2:-900}" + local strict_fileops="${3:-0}" local result if ! command -v python3 >/dev/null 2>&1; then @@ -50,7 +51,7 @@ check_dlp_transport_freshness() { return fi - result="$(python3 - "$api_base" "$max_age_seconds" <<'PY' + result="$(python3 - "$api_base" "$max_age_seconds" "$strict_fileops" <<'PY' import json import sys import time @@ -58,6 +59,7 @@ from urllib.request import urlopen api_base = sys.argv[1].rstrip("/") max_age = int(sys.argv[2]) +strict_fileops = str(sys.argv[3]).strip().lower() in ("1", "true", "yes", "on") now = time.time() def parse_ts(ts): @@ -114,8 +116,11 @@ def check_bucket_freshness(bucket_id, label): return age = int(now - end) if age > max_age: - out["ok"] = False - out["errors"].append(f"{label}:stale:{bucket_id}:age={age}s") + if label == "fileops" and not strict_fileops: + out["warnings"].append(f"{label}:stale:{bucket_id}:age={age}s") + else: + out["ok"] = False + out["errors"].append(f"{label}:stale:{bucket_id}:age={age}s") for bid in endpoint: check_bucket_freshness(bid, "endpoint") @@ -177,7 +182,7 @@ echo # Check API endpoints check_api_endpoint "http://127.0.0.1:5600/api/0/info" "activitywatch-server" check_api_endpoint "http://127.0.0.1:5610/reports/worktime/today" "aw-worktime-api" -check_dlp_transport_freshness "http://127.0.0.1:5600/api/0" "900" +check_dlp_transport_freshness "http://127.0.0.1:5600/api/0" "900" "${AW_HEALTH_STRICT_FILEOPS:-0}" echo