@@ -8,7 +8,10 @@ BACKEND_RETRY_DELAY_SEC="${NULL_BACKEND_RETRY_DELAY_SEC:-2}"
88ENABLE_BACKEND_SMOKE=" ${NULL_ENABLE_BACKEND_SMOKE:- 1} "
99REPORT_FILE=" ${NULL_OPS_REPORT_FILE:- } "
1010HISTORY_FILE=" ${NULL_OPS_HISTORY_FILE:- } "
11+ STALE_HOURS_THRESHOLD=" ${NULL_STALE_HOURS:- 168} "
12+ STRICT_STALE_FAIL=" ${NULL_STRICT_STALE_FAIL:- 0} "
1113FAILURES=0
14+ STALE_ALERT=false
1215
1316run_check () {
1417 local label=" $1 "
@@ -80,10 +83,35 @@ if [[ "$ENABLE_BACKEND_SMOKE" == "1" ]]; then
8083 done
8184fi
8285
86+ check_repo_activity () {
87+ local repo_root latest_commit_epoch latest_commit_iso now_epoch age_hours
88+ repo_root=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) /.." && pwd) "
89+ latest_commit_epoch=" $( git -C " $repo_root " log -1 --format=%ct 2> /dev/null || echo 0) "
90+ latest_commit_iso=" $( git -C " $repo_root " log -1 --format=%cI 2> /dev/null || echo unknown) "
91+ now_epoch=" $( date +%s) "
92+
93+ if [[ " $latest_commit_epoch " =~ ^[0-9]+$ ]] && (( latest_commit_epoch > 0 )) ; then
94+ age_hours=$(( (now_epoch - latest_commit_epoch) / 3600 ))
95+ else
96+ age_hours=999999
97+ fi
98+
99+ if (( age_hours >= STALE_HOURS_THRESHOLD )) ; then
100+ STALE_ALERT=true
101+ echo " [null] repo activity: stale (${age_hours} h >= ${STALE_HOURS_THRESHOLD} h, latest=${latest_commit_iso} )"
102+ if [[ " $STRICT_STALE_FAIL " == " 1" ]]; then
103+ FAILURES=$(( FAILURES + 1 ))
104+ fi
105+ else
106+ echo " [null] repo activity: fresh (${age_hours} h < ${STALE_HOURS_THRESHOLD} h, latest=${latest_commit_iso} )"
107+ fi
108+ }
109+
83110echo " [null] checking frontend: ${FRONTEND_URL} "
84111for path in " /" " /en" ; do
85112 check_once frontend " $FRONTEND_URL " " $path " || true
86113done
114+ check_repo_activity
87115
88116if [[ " $FAILURES " -gt 0 ]]; then
89117 status=" fail"
95123 code=0
96124fi
97125
98- summary=" {\" service\" :\" null\" ,\" status\" :\" ${status} \" ,\" failures\" :${FAILURES} ,\" backend\" :\" ${BACKEND_URL} \" ,\" frontend\" :\" ${FRONTEND_URL} \" ,\" ts\" :\" $( date -u +%Y-%m-%dT%H:%M:%SZ) \" }"
126+ summary=" {\" service\" :\" null\" ,\" status\" :\" ${status} \" ,\" failures\" :${FAILURES} ,\" staleHoursThreshold \" : ${STALE_HOURS_THRESHOLD} , \" staleAlert \" : ${STALE_ALERT} , \" strictStaleFail \" : ${STRICT_STALE_FAIL} , \" backend\" :\" ${BACKEND_URL} \" ,\" frontend\" :\" ${FRONTEND_URL} \" ,\" ts\" :\" $( date -u +%Y-%m-%dT%H:%M:%SZ) \" }"
99127
100128if [[ -n " $REPORT_FILE " ]]; then
101129 printf ' %s\n' " $summary " > " $REPORT_FILE "
0 commit comments