Welcome! Log In Create A New Profile

Advanced

Having problems with starting ezstream in rc.local script

Posted by maihoaomv 
Having problems with starting ezstream in rc.local script
December 31, 2012 03:06PM
I installed and configured icecast and ezstream to run on my GoFlexHome to stream music on my LAN. It works perfectly but I run into a problem when I try to autostart ezstream in the /etc/rc.local file. Icecast is daemonized but ezstream has to be started from the command line such as this:
/usr/bin/ezstream -c /home/maihoa/jazz_mp3.xml &
This works just fine and I get a single line on stdout such as this for each track as it streams it:
ezstream: Streaming ``Lu Watters Yerba Buena Jazz BaThe San Francisco Style Good T1946Track 10 Lu Watters Yerba Bu - Ory's Creole Trombone''
I can listen to the stream on another computer and I can even play the stream on the server itself using mpg321 with no problems. but when I put this command in /etc/rc.local file I get something like this as soon as it starts:
Starting S.M.A.R.T. daemon: smartd.
Making sure that Logitech Media Server is not running first: No process in pidfile '/var/run/logitechmediaserver.pid' found running; none killed.
Starting Logitech Media Server.
Turning on White LED
ezstream: Connected to http://192.168.1.180:8000/jazz
ezstream: Streaming ``The Bay City Jazz Band - Snake Rag''
Stopping watchdog keepalive daemon....
Starting watchdog daemon....
ezstream: Streaming ``Lu Watters Yerba Buena Jazz BaThe San Francisco Style Good T1946Track 12 Lu Watters Yerba Bu - Canal Street Blues''
                                                         ezstream: Streaming ``Bob Scobey's Frisco Band - St James Infirmary''
                                              ezstream: Streaming ``Lu Watters Yerba Buena Jazz BaVol. 2 WATTERS ORIGINALS AND R1946Track 01 Lu Watters Yerba Bu - Annie Street Rock''

OpenMediaVault 0.4.10 (Fedaykin) GoFlexHome ttyS0
Copyright (C) 2009-2012 by Volker Theile. All rights reserved.

To manage the system visit the OpenMediaVault web administration
interface via a web browser on:

eth0: 192.168.1.180

For more information regarding this appliance, please visit
the web site: http://www.openmediavault.org

GoFlexHome login: ezstream: Streaming ``Kid Ory's Creole Jazz Band - Tin Roof Blues''
     ezstream: Streaming ``Lu Watters Yerba Buena Jazz BaThe San Francisco Style Good T1946Track 07 Lu Watters Yerba Bu - Ain't Gonna Give Nobody None OLu Watters Yerba Buena Jazz BaThe San Francisco Style Good T1946Track 07 Lu Watters Yerba Bu''
      ezstream: Streaming ``Lu Watters' Yerba Buena Jazz BGood Time Jazz - Riverside Blues''
            ezstream: Streaming ``Kid Ory's Creole Jazz Band - A Closer Walk With Thee''
        ezstream: Streaming ``The Bay City Jazz Band - How'm I Gonna Do It (If I Don'The Bay City Jazz Band''
                             ezstream: Streaming ``Bob Scobey's Frisco Band - Angry''
     ezstream: Streaming ``Lu Watters' Yerba Buena Jazz BGood Time Jazz - Tiger Rag''
     ezstream: Streaming ``Bob Scobeys Frisco Band - Some Of These Days''
                                                                         ezstream: Streaming ``Lu Watters Yerba Buena Jazz BaThe San Francisco Style Good T1946Track 05 Lu Watters Yerba Bu - Pineapple Rag''
                                             ezstream: Streaming ``Lu Watters Yerba Buena Jazz BaVol. 2 WATTERS ORIGINALS AND R1946Track 09 Lu Watters Yerba Bu - Harlem Rag''
              ezstream: Streaming ``The Bay City Jazz Band - Yerba Buena Blues''
ezstream: Streaming ``The Bay City Jazz Band - Potato Head''
                                                            ezstream: Streaming ``Lu Watters Yerba Buena Jazz BaVol. 2 WATTERS ORIGINALS AND R1946Track 08 Lu Watters Yerba Bu - Down Home Rag''
It repeats this over and over continiously as if it's trying to stream all the tracks at once instead of one at a time. The CPU time for ezstream is usually very low around .3% (per top) but when I try to run it from rc.local the CPU time is up around 35% to 50%. It appears to be working if I tune into it from another computer. But if I try to play the stream on the server using mpg321, mpg abouts after a few seconds and refuses to play.

This is my rc.local file:
cat /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

#echo "checking if icecast is running"
#ps aux |grep icecast2

#autostart minidlna
#if [ "$(runlevel)" = "N 2" ]; then
#echo  "Starting minidlna ........"
#minidlna -R -f /etc/minidlna.conf
#fi

# autostart ezstream
if [ "$(runlevel)" = "N 2" ]; then
#echo  "Starting ezstream ........"
/usr/bin/ezstream -c /home/maihoa/jazz_mp3.xml &
#    /usr/bin/ezstream -q -c /home/maihoa/jazz_mp3.xml > /dev/null 2>&1 &
fi


# Turn on the white LED
echo "Turning on White LED"
if [ -d /sys/class/leds/status:white:misc ]; then
   echo default-on > /sys/class/leds/status:white:misc/trigger
fi

exit 0

It won't stop long enough so I can login in and kill the ezstream process. In order to do anything on the command line I have to ssh into the GFH and kill ezstream from there and as far as I can tell there is only one ezstream process running. I've tried it with and without the runlevel checking but with the same results.
What am I doing wrong?
Re: Having problems with starting ezstream in rc.local script
January 01, 2013 01:35AM
What if you log in throu ssh and start it as background proc with the same command?

Also, You can always daemonize the ezstream at certain run level you like, too. A quick test: ar a run level you want, creating Sxx script (cloning another Sxx script) and run ezstream from this script.
Re: Having problems with starting ezstream in rc.local script
January 03, 2013 11:25AM
Hi bodhi
thank you for your replay. I really appreciate you taking the time to help me with this problem. I tried daemonizing ezstream the way you suggested but with the same results. It seems there may be a bug in ezstream in that something has to be up and stabilized (icecast I assume) before it will run properly. I tried setting up the daemon so that ezstream would not start until icecast and the network were up. I tried adding a sleep command to the rc.local script to allow some extra time for everything to stabilize before starting ezstream. Sometimes this would work and sometimes it would not.

So in conclusion what seemed to work the best was adding an AT command in the rc.local file so ezstream would delay starting for 2 minutes afterwards to give things time to stabilize.

In the process I learned something about how to create and install a daemon. My knowledge of Linux is limited so there is not much that I can contribute in the way of helping anyone. As small as it may be this is the solution I came up with in the hope that it might help someone else if they should also have a similar problem.
# autostart ezstream
if  [ "$(pidof ezstream)" > 0 ]; then
    echo  "ezstream is running already ........"
    else
        if  [ "$(pidof icecast2)" > 0 ]; then
            echo "Starting ezstream ..........."
at -m -f /home/maihoa/jazz.sh now + 2 min
        fi
fi

Once again thanks
Re: Having problems with starting ezstream in rc.local script
January 04, 2013 12:55AM
@maihoamv,

Hey :-) we're never stop learning and helping each other in some way. Nice script! I'm sure I will use it someday.
I know this is a little off topic, but here is a script I wrote to manage Ezstream. Some might find it helpful:

#!/bin/bash
#Tool to change song streaming with EZStream, refresh playlist, or kill instance
#Ethan Irish
#1/22/2014


while :
do
clear
echo -e " \e[31mEZstream Menu\e[0m"
echo " "
echo " Simple Tool To Manage Ezstream"
echo " "
echo " "
echo "|PID| |SERVICE| |OPT| |Full Ezstream Command with config|"
echo "| | | | | | | | "
pgrep -lf "ezstream" | grep -v "log"
echo "| | | | | | | | "
echo " "
echo "++++++++++END PROC LIST+++++++"
echo ""
echo -n "Please select a PID to change status: "

read pid

if [[ -z "$pid" ]]; then
echo "You cannot pass nothing as a variable.. come'on"
read pid
else

echo "Enter 1 to skip song"
echo "Enter 2 to refresh playlist"
echo "Enter 3 to refresh metadata"
echo "Enter 4 to Kill this Process"
echo "Enter 5 to Exit Ezstream Menu"
echo -n "Option: "
fi


read opt

case "$opt" in
1) kill -SIGUSR1 $pid
echo "$pid was triggered to skip current song"
sleep 3
;;
2) kill -SIGHUP $pid
echo "$pid was triggered to refresh it's playlist"
sleep 3
;;
3) kill -SIGUSR2 $pid
echo "$pid's metadata has been updated"
sleep 3
;;
4) kill -15 $pid
echo "$pid has been sent a signal 15. Bye Bye"
sleep 3
;;
5) break
echo "GoodBye"
;;
*) echo "You don't know what you're selecting... go home"
sleep 10
;;
esac


done
hello, i have a last project about radio streaming. usually, i use ezstream on linux for run my audio streaming. but now how can run ezstream on the website??so, my song while i run can run automatically.. what should i do first?? please answer it. thank you..
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: