From 260f0a61ce315b8170f9d7fba20a581e338dc5ce Mon Sep 17 00:00:00 2001 From: Gmer4Lfe Date: Fri, 3 Jul 2026 17:45:20 -0400 Subject: [PATCH] Wire up unused config vars found in follow-up audit pass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TRANSCODE_LOG_RETENTION was documented as trimming the daily transcode log but never referenced — log grew unbounded. TRANSCODE_ORPHAN_AGE was shown in --status but never used, so empty session folders were deleted immediately instead of after the documented grace period, risking a race against ffmpeg creating a folder just before writing its first segment. docker_watchdog.sh's daemon-health thresholds were only hardcoded fallbacks despite comments claiming they were master.conf-configurable, and it referenced a heartbeat feature that was never implemented (that's owned by watchdog_orchestrator.sh, its caller) — added the three thresholds to master.conf for real and removed the stale heartbeat claim. Also added the missing HOSTN_PARTNERSHIP_SERVICES_STACK block to host.conf.template (containers.sh already read it via detect_hosts, just never had a template entry) and corrected play_state_sync.sh's doc comment for PLAY_SYNC_TYPES' actual default. --- Configurations/master.conf | 5 +++++ Deployment/host.conf.template | 5 +++++ Deployment/master.conf.template | 5 +++++ Media/play_state_sync.sh | 3 ++- Transcodes/transcode_cleanup.sh | 7 ++++--- Transcodes/transcode_manager.sh | 8 ++++++++ Watchdogs/docker_watchdog.sh | 8 +++++--- 7 files changed, 34 insertions(+), 7 deletions(-) diff --git a/Configurations/master.conf b/Configurations/master.conf index 52ee483..870a2fe 100644 --- a/Configurations/master.conf +++ b/Configurations/master.conf @@ -813,6 +813,11 @@ # Notification batching — one summary per cycle instead of one ping per event WATCHDOG_BATCH_NOTIFY=true +# Docker daemon health check — hung daemon detection at the start of each cycle + WATCHDOG_DAEMON_TIMEOUT=20 # seconds — timeout for all docker commands + WATCHDOG_DAEMON_STRIKE_LIMIT=3 # consecutive failed checks before restart attempt + WATCHDOG_DAEMON_RESTART_WAIT=900 # seconds to wait after restart before verifying + # Appdata size monitoring — two-part catch-all for runaway growth and oversized log files. # # Part 1 — Growth rate (zero-config): diff --git a/Deployment/host.conf.template b/Deployment/host.conf.template index e91e8ba..69c3f20 100644 --- a/Deployment/host.conf.template +++ b/Deployment/host.conf.template @@ -151,6 +151,11 @@ # "my-Radarr.xml" ) +# XML templates pushed to mirror during onboard — other services (not auth, not arr). + HOSTN_PARTNERSHIP_SERVICES_STACK=( + # "my-Lidarr.xml" + ) + # Paths the partner should collect during the grace window after offboard. HOSTN_PARTNERSHIP_MIRROR_BACKUPS=( # "/mnt/user/appdata-Fallback/Partner-Emby" diff --git a/Deployment/master.conf.template b/Deployment/master.conf.template index 17a6822..98fa6ce 100644 --- a/Deployment/master.conf.template +++ b/Deployment/master.conf.template @@ -808,6 +808,11 @@ # Notification batching — one summary per cycle instead of one ping per event WATCHDOG_BATCH_NOTIFY=true +# Docker daemon health check — hung daemon detection at the start of each cycle + WATCHDOG_DAEMON_TIMEOUT=20 # seconds — timeout for all docker commands + WATCHDOG_DAEMON_STRIKE_LIMIT=3 # consecutive failed checks before restart attempt + WATCHDOG_DAEMON_RESTART_WAIT=900 # seconds to wait after restart before verifying + # Appdata size monitoring — two-part catch-all for runaway growth and oversized log files. # # Part 1 — Growth rate (zero-config): diff --git a/Media/play_state_sync.sh b/Media/play_state_sync.sh index f91f4e0..8f279ef 100755 --- a/Media/play_state_sync.sh +++ b/Media/play_state_sync.sh @@ -79,7 +79,8 @@ # false = local servers only (this host's Emby + Jellyfin) # PLAY_SYNC_DAYS How many days back to check for played items (default: 90) # Use 0 to sync all played items (slow on large libraries). -# PLAY_SYNC_TYPES Comma-separated item types to sync (default: Movie,Episode,Audio) +# PLAY_SYNC_TYPES Comma-separated item types to sync (default: Movie,Episode — +# Audio excluded, music library too large; favorites handled separately) # # ============================================================================================== # RUNTIME MODES diff --git a/Transcodes/transcode_cleanup.sh b/Transcodes/transcode_cleanup.sh index 3d10095..e46032b 100755 --- a/Transcodes/transcode_cleanup.sh +++ b/Transcodes/transcode_cleanup.sh @@ -230,10 +230,11 @@ cleanup_location() { done < <(find "$location" -type f -mmin +"$max_age" 2>/dev/null) - # Remove empty directories — but NEVER remove transcoding-temp - # transcoding-temp must always exist on ramdisk so Emby finds it there first + # Remove empty directories older than TRANSCODE_ORPHAN_AGE — but NEVER remove + # transcoding-temp. Age gate avoids deleting a session folder ffmpeg just + # created but hasn't written its first segment into yet. if [[ "$DRY_RUN" == false ]]; then - find "$location" -mindepth 1 -type d -empty \ + find "$location" -mindepth 1 -type d -empty -mmin +"${TRANSCODE_ORPHAN_AGE:-30}" \ ! -name "transcoding-temp" -delete 2>/dev/null fi diff --git a/Transcodes/transcode_manager.sh b/Transcodes/transcode_manager.sh index 871414d..2177ea6 100755 --- a/Transcodes/transcode_manager.sh +++ b/Transcodes/transcode_manager.sh @@ -647,6 +647,14 @@ if [[ "$DRY_RUN" == false && "$NO_LOG" == false && -n "${TRANSCODE_DAILY_LOG:-}" echo "${TODAY}|${RAMDISK_USED_GB}|${FLIP_COUNT}|${RAM_SESSION_COUNT}|${SSD_SESSION_COUNT}" \ >> "$TRANSCODE_DAILY_LOG" 2>/dev/null || true log "Daily log written: $TRANSCODE_DAILY_LOG" + + # Trim entries older than TRANSCODE_LOG_RETENTION days + LOG_CUTOFF=$(date -d "${TRANSCODE_LOG_RETENTION:-90} days ago" '+%Y-%m-%d' 2>/dev/null) + if [[ -n "$LOG_CUTOFF" ]]; then + awk -F'|' -v cutoff="$LOG_CUTOFF" '$1 >= cutoff' "$TRANSCODE_DAILY_LOG" \ + > "${TRANSCODE_DAILY_LOG}.tmp" 2>/dev/null && \ + mv "${TRANSCODE_DAILY_LOG}.tmp" "$TRANSCODE_DAILY_LOG" + fi fi # ============================================================================================== diff --git a/Watchdogs/docker_watchdog.sh b/Watchdogs/docker_watchdog.sh index c1866f7..aa3949b 100755 --- a/Watchdogs/docker_watchdog.sh +++ b/Watchdogs/docker_watchdog.sh @@ -82,7 +82,8 @@ # # Silent When Healthy # Runs 96 times per day. Producing output on every clean cycle would make -# logs useless. Output only when something needs attention or a heartbeat fires. +# logs useless. Output only when something needs attention — alive heartbeat +# is handled by watchdog_orchestrator.sh, the caller, not this script. # # ============================================================================================== # OPERATIONAL SAFEGUARDS @@ -196,8 +197,9 @@ # WATCHDOG_BATCH_NOTIFY # Collect cycle events and send as one notification (default: true) # -# DOCKER_WATCHDOG_HEARTBEAT_HOURS -# Hours between alive heartbeat log entries +# WATCHDOG_DAEMON_TIMEOUT / WATCHDOG_DAEMON_STRIKE_LIMIT / WATCHDOG_DAEMON_RESTART_WAIT +# Docker daemon health check: command timeout, strikes before restart attempt, +# seconds to wait after restart before verifying # # DOCKER_WATCHDOG_INTENTIONAL_FILE # Path to intentional stops state file (STATE_DIR). Containers in this file