Obligatory warning:
NEVER RUN A SCRIPT UNLESS YOU UNDERSTAND WHAT IT DOES.
not from me, not from Microsoft, Arch,github or anywhere/anyone else.
There was an old topic on this, but I didnt want to revive it (usually frowned upon). I hope the following helps someone else.
First i checked the link that was displayed when starting this topic.
I had an issue where the music playing would stop, and would not restart.The mpd.log file exhibited the following:
Dec 13 07:08 : client: Max connections reached
Dec 13 07:08 : client: Max connections reached
Dec 13 07:08 : client: Max connections reached
Dec 13 07:08 : client: Max connections reached
Dec 13 07:08 : client: Max connections reached
Dec 13 07:09 : client: Max connections reached
Dec 13 07:09 : client: Max connections reached
Dec 13 07:09 : client: Max connections reached
Dec 13 07:09 : client: Max connections reached
Dec 13 07:09 : client: Max connections reached
After some research i found that issuing
systemctl restart volumio.service
would return volumio to normal.
More research returned this script ([question] How can we start automatically the player when volumio reboots · Issue #1693 · volumio/Volumio2 · GitHub)
#/bin/sh
date >> aplay.txt
volumio=localhost:3000/api/v1/commands
until $(curl --silent --output /dev/null --head --fail ${volumio}); do
echo "We wait till volumio is up and running" >>aplay.txt
sleep 5s
done
until curl --silent localhost:3000/api/v1/getState | grep -q '"status":"play"';
do
echo "starting..." >>aplay.txt
curl --silent ${volumio}/?cmd=play >>aplay.txt
sleep 5s
done
echo "done" >>aplay.txt
This script was meant to autoplay the playlist on reboot. I adapted it to the following:
#/bin/sh
#this 1st bit my me, minifang
#check mpd.log for errors
error=$(grep "Max connections reached" /var/log/mpd.log |grep "$(date +%b" "%d" "%H)")
#if an error (Max connections reached) is found restart volumio.service
#if not found log results,do nothing else
if [ "$error" != "" ]; then
/bin/systemctl restart volumio.service
echo $(date) "error" >>/var/log/volumio.log
else
echo $(date)" no errors" >>/var/log/volumio.log
fi
#credit: AndreiPuchko https://github.com/AndreiPuchko posted on https://github.com/volumio/Volumio2/issues/1693
#altered paths to use with cron -minifang
PATH=$PATH:/root:/usr/bin:/bin
date > /root/aplay.txt
volumio=localhost:3000/api/v1/commands
until $(curl --silent --output /dev/null --head --fail ${volumio}); do
echo "We wait till volumio is up and running" >>/root/aplay.txt
sleep 5s
done
until curl --silent localhost:3000/api/v1/getState | grep -q '"status":"play"';
do
echo "starting..." >>/root/aplay.txt
curl --silent ${volumio}/?cmd=play >>/root/aplay.txt
sleep 5s
done
echo "done" >>/root/aplay.txt
You may wish to alter the location of aplay.txt to /var/log, up to you
I also did a apt update, then a apt install cron.
set cron to run the script every minute
crontab -e
then add
* * * * * /path/to/script
Save and quit
This seems to have been a decent workaround for my issues.
Hardware:
Raspberry pi 3b+
Usb 7.1 soundcard startech model ICUSBAUDIO7.1
some generic powered speakers (edifier 1280t on the way though)