From eb86faddcd4a170b465e3ac45d182412c4c67886 Mon Sep 17 00:00:00 2001 From: Steve Dodd Date: Fri, 11 Aug 2023 22:33:46 +0100 Subject: [PATCH] In certain situations trying to recover from stalled analysis we can end up with low / no disk space and be unable to "escape." In the event of a backlog, the loop in birdnet_analysis.sh runs continuously, which means analyzed files do not get moved, which means in turn extract_new_birdsounds.sh cannot create mp3 extractions and move the processed files again, which would allow them to be cleaned up by the cron jobs. This patch is the obvious fix, i.e. to just limit the maximum amount of files birdnet_analysis.sh can process to 20. This should be a good trade off given the small overhead of listing files etc before the main loop begins - note that for the "normal" case of no backlog, birdnet_analysis usually exits after a single analysis anyway. --- scripts/birdnet_analysis.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/birdnet_analysis.sh b/scripts/birdnet_analysis.sh index aadf6f8..633c1e7 100755 --- a/scripts/birdnet_analysis.sh +++ b/scripts/birdnet_analysis.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env -S --default-signal=PIPE bash # Runs BirdNET-Lite #set -x source /etc/birdnet/birdnet.conf @@ -52,6 +52,7 @@ fi get_files() { files=($( find ${1} -maxdepth 1 -name '*wav' ! -size 0\ | sort \ + | head -n 20 \ | awk -F "/" '{print $NF}' )) [ -n "${files[1]}" ] && echo "Files loaded" }