View Single Post
Old 26th January 2011, 17:22   #68
Junior Member
Join Date: Oct 2010
Posts: 16
Originally Posted by cuddles71 View Post
I've been getting that for a few weeks now.

My solution was to write a small bash script and run it as a cron job. Once a minute it checks the DNAS page looking for the words "Server is offline" and when it finds that, it restarts sc_trans.
Great idea! I've implemented something like this now with a wonderful PHP script. I'll post it here since perhaps it will be useful to someone else. I haven't tested the restarting part yet, but I think it will work.

This has caused me to have more downtime than ever before, so I really hope this gets fixed in the next drop of sc_trans.

PHP Code:
//the shoutcast server domain name or ip address
$server "";
//the port your shoutcast server is on
$port "80";

$connect = @fsockopen($server$port$errno$errstr10);

fputs($connect,"GET /7.html HTTP/1.0\r\nUser-Agent: SC Status (Mozilla Compatible)\r\n\r\n");
$contents .= fgets($connect1024);

$contents ereg_replace(".*<body>"""$contents);
$contents ereg_replace("</body>.*"","$contents);
$sc_contents explode(",",$contents);
$dsp_connected $sc_contents[1];

$dsp_connected != '1')
"sc_trans fails :(";
exec("kill -9 `ps -C sc_trans -o pid --no-headers`;
        cd /home/shoutcast/sc_trans/;
        ./sc_trans ./sc_trans.conf > /dev/null 2>&1;"
"Shoutcast server reports that it is receiving a stream. Therefore, no action is necessary.";
"Cannot connect to Shoutcast server. Please check your config.";
audioprobe is offline