[darkice] Re: watch darkice errors and restart if necessarily

  • From: Hungerburg <pch13@xxxxxxxxx>
  • To: darkice@xxxxxxxxxxxxx
  • Date: Mon, 16 Jan 2012 00:43:37 +0100

Am 2012-01-15 19:09, schrieb JoergSorge:
Am 15.01.2012 18:37, schrieb Hungerburg:
In such a case I would truncate the log file beforehand, so any match
could trigger. To sum it up, this is what you may use instead of
./srb-stream-xy.sh. Some messages and error conditions added:

#!/bin/sh
while (true) ; do
     # maybe check for working uplink first?
     while (! ping -c1 some.net ) ; do sleep 1; done
     # ok, proceed
     echo -e "\n### STARTING STREAM\n"
     darkice -c my.conf 3>&1 1>&2 2>&3 \
         | grep -q "failed to write to ring"
     echo -e "\n## ERROR FOUND\n"
     # will this ever happen that darkice is still alive?
     # wont we be not here, then?
     sleep 2; killall darkice || echo -e "\n## DI NOT RUNNING\n"
     sleep 2
done

Happy hacking

ok, slowly, I understand, but it is one thing here, why I use Niels'
rc-script. I have to manage several streams! So I can't use killall?

Jörg, in my understanding, if darkice does not trap SIGPIPE, the killall line will always print "DI not running" (if there was only one instance, of course) - and if darkice does trap SIGPIPE, the script will never get to that point. Because then darkice will remain in foreground and the script will not advance. So this line can be simply dropped, I guess.

Second Question: To use additionally a logfile, I can write:

darkice -c my.conf 3>&1 1>&2 2>&3>  my.log

And when I use your example: Blocks this my Terminal, when darkice run
not in the background?

If you do not want to block the terminal, this script is not useful. You better log to file then. This is very simple: "$ darkice -c my.conf 2>&1 > my.log" - As Niels did suggest, a good idea, there are apps that monitor files for changes, I know "incrond, which is very flexible and lean on resource usage. Just start a new log file with every restart, so you dont have to count rows... Niels, do you listen?

Darkice code is very clean. The person who designed the ring buffer did something though, that I could not wrap my head around and modify to handle network congestion more gracefully. Fortunately I found edcast-jack back then. It also as its quirks, yet I dont look back. But kept subscribed to this list ;)

Bye

--
peter




Other related posts: