This commit is contained in:
Alexandre
2024-05-01 16:24:10 +02:00
committed by GitHub
parent 71d6c0e24c
commit 637479c8d9
7 changed files with 0 additions and 49 deletions

View File

@@ -1,49 +0,0 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
#
# Stop the recordings while the analysis catches up
# Adapted from https://github.com/mcguirepr89/BirdNET-Pi/issues/393#issuecomment-1166445710
#
echo "Starting service: throttlerecording"
touch "$HOME"/BirdSongs/StreamData/analyzing_now.txt
# Avoid unbound errors
set +u
source /config/birdnet.conf
srv="birdnet_recording"
analyzing_now="."
counter=10
while [ 1 ];do
sleep 61
if [ $counter -le 0 ];then
latest=$(cat "$RECS_DIR"/StreamData/analyzing_now.txt)
if [ "$latest" = "$analyzing_now" ];then
echo "$(date) WARNING no change in analyzing_now for 10 iterations, restarting services"
sudo -u pi "$HOME"/BirdNET-Pi/scripts/restart_services.sh
fi
counter=10
analyzing_now=$(cat "$HOME"/BirdSongs/StreamData/analyzing_now.txt)
fi
if [ -z "${RTSP_STREAM}" ];then
ingest_dir=${RECS_DIR}/$(date +"%B-%Y/%d-%A")
mkdir -p "$ingest_dir"
else
ingest_dir="$RECS_DIR"/StreamData
fi
wavs=$(ls ${ingest_dir}/*.wav | wc -l)
if [ $(systemctl --state=active | grep $srv | wc -l) -eq 0 ];then
state="inactive"
else
state="active"
fi
echo "$(date) INFO ${wavs} wav files waiting in $(readlink -f $ingest_dir), $srv state is $state"
if [ "$wavs" -gt 100 -a "$state" = "active" ];then
sudo systemctl stop "$srv"
echo "$(date) WARNING stopped $srv service"
elif [ $wavs -le 100 -a $state = "inactive" ];then
sudo systemctl start $srv
echo "$(date) INFO started $srv service"
fi
((counter-=1))
done