[icecast] Propping up liveice

Matt Boersma matt at sprout.org
Fri May 24 18:43:46 UTC 2002



I'm a volunteer who runs the mp3 streaming for KGNU-FM in Boulder, 
Colorado.  We stream live at 64K with Linux, icecast 1.3.12+ minor 
patches, liveice, and lame 3.92.  It easily supports 32 internet 
listeners 24x7 from a donated 400MHz Pentium II.

Liveice is the only problem--it does its job of connecting the soundcard 
rec in to the lame encoder and to icecast, but dies without explanation 
on the average of every couple weeks.  I tried darkice, but it doesn't 
deal with lame correctly.  So I wrote a script to resurrect liveice when 
needed.  It is very specific to our setup, because it expects a certain 
number of process ids (threads) to be there.  Root runs this every five 
minutes via cron like this:
*/5 * * * * /usr/local/icecast/bin/check_icecast

We now average about 60 seconds of downtime a month, and I can leave the 
server totally unattended.  I hope this is of use to someone else, and I 
welcome any suggestions.  Here's the script:

#!/bin/sh
#
# check_icecast
#
# This script ensures that icecast, liveice, and lame are alive, and
# restarts them if they're not.  It checks for an expected number of
# process ids owned by "nobody".  If those aren't found, it kills any
# stragglers and runs the appropriate startup script.  It uses pgrep
# (find process by wildcard) and wc (word count).
#
# If everything looks alive, this script outputs nothing.  Otherwise,
# it reports what had to be restarted and when.  This script is
# intended to be run often via cron.
#
# TODO: It's possible that all the processes are alive, but that the
# liveice source has become disconnected from the icecast server
# somehow.  We need a way to check for this condition, too.

LIVEICE_PIDS=`pgrep -u nobody 'liveice|lame'`
LIVEICE_PIDNUM=`echo $LIVEICE_PIDS | wc -w`
ICECAST_PIDS=`pgrep -u nobody 'icecast'`
ICECAST_PIDNUM=`echo $ICECAST_PIDS | wc -w`

if [ "$ICECAST_PIDNUM" -lt "6" ] ; then
    kill -9 $LIVEICE_PIDS $ICECAST_PIDS >/dev/null 2>/dev/null
    sleep 5
    cd /usr/local/icecast/bin
    su nobody -c ./start_streaming
    echo "icecast restarted at `date`"
    renice -1 `pgrep -u nobody 'liveice|lame|icecast'`
else
    if [ "$LIVEICE_PIDNUM" -lt "3" ] ; then
        kill -9 $LIVEICE_PIDS >/dev/null 2>/dev/null
        sleep 5
        cd /usr/local/icecast/bin
        su nobody -c ./start_liveice
        echo "liveice restarted at `date`"
        renice -1 `pgrep -u nobody 'liveice|lame'`
    fi
fi

<p>--- >8 ----
List archives:  http://www.xiph.org/archives/
icecast project homepage: http://www.icecast.org/
To unsubscribe from this list, send a message to 'icecast-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the Icecast mailing list