Hi Savonet,

Just wanted to share some experience as a happy user of your wonderful
project! Not sure if it has already been mentioned on here, but I find it
really useful for production use and it works like a charm.

I have a setup where a computer is used for making music, and its output
(from an 8 channel soundcard) is fed into a studio mixer, the output of
which is then fed into our dedicated streaming server that has only icecast
and liquidsoap on them. My "liq" script is simply this:

#!/usr/bin/liquidsoap

output.icecast(%mp3,
        genre="xxx",url="http://xxx.xxx.xxx";,
        description="XXXX",
        host="localhost",user="source",password="xxxx",mount="XXXX",
        input.alsa())

Unfortunately, sometimes liquidsoap crashes due to a segfault in mp3
encoding (I presume), which is no that big a deal, since the program starts
and stops almost instantaneously. That is why I decided to make a simple
cron restart script that runs once every minute and I haven't regretted
that. The downtime is always <1 min and I personally haven't noticed any,
even though the logs mention a few instances when this happened (about 1-4
times per day).

First is a PHP script that checks if liquidsoap is up and and restarts it if
it's not. It uses Curl to download the stream through Icecast:

#!/usr/bin/php
<?
        $ch = curl_init("http://localhost:8000/MOUNT_HERE";);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);//download some data
(it doesn't work without this)
        curl_setopt($ch, CURLOPT_TIMEOUT, 1);//disconnect after a second
        curl_exec($ch);//connect
        $retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);//check return code
        curl_close($ch);

        if($retcode==404)
        {
                echo("Liquidsoap down! Restarting!\n");
                passthru("/etc/init.d/liquidsoap start");
        }
        else echo("Liquidsoap is up! Everything is fine!\n");
?>

I run this from a shell script which sets the path (for the initscript) and
also does some logging:

#!/bin/bash

#add sbin to the path when run from cron
PATH=$PATH:/sbin

#check the size of the log and delete it if it gets too big
touch Radio.log
size=`wc -c Radio.log | cut -f 1 -d " "`
if [ $size -gt 10000000 ]
then
        rm Radio.log
fi

date >> /root/Radio.log
/usr/bin/php /root/RadioKeepAlive.php >> /root/Radio.log

The script is then run with cron by placing a file in /etc/cron.d (under
debian):

# /etc/cron.d/radio: crontab for checking/fixing Liquidsoap radio every
minute.

* * * * *       root    /root/RadioKeepAlive.sh


Not sure if anyone will find this useful, but in case you do, feel free to
use it as public domain.
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to