diff --git a/action/action-poll.sh b/action/action-poll.sh index 1ec6814..100d854 100755 --- a/action/action-poll.sh +++ b/action/action-poll.sh @@ -25,11 +25,7 @@ log() { } # --- Memory guard --- -AVAIL_MB=$(awk '/MemAvailable/{printf "%d", $2/1024}' /proc/meminfo) -if [ "$AVAIL_MB" -lt 2000 ]; then - log "SKIP: only ${AVAIL_MB}MB available (need 2000MB)" - exit 0 -fi +memory_guard 2000 # --- Find open 'action' issues --- log "scanning for open action issues" diff --git a/dev/dev-poll.sh b/dev/dev-poll.sh index effeea2..1f81287 100755 --- a/dev/dev-poll.sh +++ b/dev/dev-poll.sh @@ -309,11 +309,7 @@ if [ -f "$LOCKFILE" ]; then fi # --- Memory guard --- -AVAIL_MB=$(awk '/MemAvailable/{printf "%d", $2/1024}' /proc/meminfo) -if [ "$AVAIL_MB" -lt 2000 ]; then - log "SKIP: only ${AVAIL_MB}MB available (need 2000MB)" - exit 0 -fi +memory_guard 2000 # ============================================================================= # HELPER: check if a dependency issue is fully resolved (closed + PR merged) diff --git a/lib/env.sh b/lib/env.sh index a453b40..0d0aeb6 100755 --- a/lib/env.sh +++ b/lib/env.sh @@ -146,6 +146,18 @@ wpdb() { -t "$@" 2>/dev/null } +# Memory guard — exit 0 (skip) if available RAM is below MIN_MB. +# Usage: memory_guard [MIN_MB] (default 2000) +memory_guard() { + local min_mb="${1:-2000}" + local avail_mb + avail_mb=$(awk '/MemAvailable/{printf "%d", $2/1024}' /proc/meminfo) + if [ "${avail_mb:-0}" -lt "$min_mb" ]; then + log "SKIP: only ${avail_mb}MB available (need ${min_mb}MB)" + exit 0 + fi +} + # Source tea helpers (available when tea binary is installed) if command -v tea &>/dev/null; then # shellcheck source=tea-helpers.sh