Icecast Streaming Media Server Forum Index Icecast Streaming Media Server
Icecast is a Xiph Foundation Project
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

on-connect scripts

 
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server
View previous topic :: View next topic  
Author Message
bbk



Joined: 15 Oct 2005
Posts: 79

PostPosted: Sat Dec 23, 2006 12:45 pm    Post subject: on-connect scripts Reply with quote

hello

i use the following <on-connect> and <on-disconnect> scripts to start a transcoding on a freebsd server.

i write a pid file for the streamtranscoder and then i kill the process when it stops.

but it just works when i start from the shell (as well with the icecast user), when i let it start automaticly from icecast it creates the file but doesn't write into it.

Code:
   <on-connect>/usr/local/share/icecast/bin/streamtranscoder1start.sh</on-connect>
<on-disconnect>/usr/local/share/icecast/bin/streamtranscoder1stop.sh</on-disconnect>


streamtranscoder1start.sh
Code:

#!/bin/sh

cd /usr/local/streamtranscoder/
/usr/local/bin/streamTranscoder -c /usr/local/streamtranscoder/streamtranscoder1.conf 1>/dev/null &
sleep 10
ps -aux |grep -v grep | grep /usr/local/streamtranscoder/streamtranscoder1.conf | awk '{print $2}' > /usr/local/streamtranscoder/pid/streamtranscoder1.pid


i tried to stop it directly without the pid file but it doesn't work neither

streamtranscoder1stop.sh
Code:


#!/bin/sh

kill -9 `ps -aux |grep -v grep | grep /usr/local/streamtranscoder/streamtranscoder1.conf | awk '{print $2}'`
kill -9 `cat /usr/local/streamtranscoder/pid/streamtranscoder1.pid`
rm /usr/local/streamtranscoder/pid/streamtranscoder1.pid


i think it is related to the way icecast starts the scritps, has anyone a idea what i do wrong or how to stop a process?

i could do some ugly things like writing into a file 0 or 1 read it out with a cronjob and then run the scripts.... but... i whould prefere to do this directly.

thx
_________________
::bbk::

http://audioasyl.net
Back to top
View user's profile Send private message Visit poster's website
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Sun Dec 24, 2006 3:10 am    Post subject: Reply with quote

The scripts are run when the stream has started or is shutting down so if the idea is that ST transcodes this stream to another mountpoint then the mechanism should be fine.

In the start script you don't need the ps/grep/awk etc to get the pid. You should be ok with just

echo $! > st.pid

Without knowing what it's actually doing then it's hard to say what the solution to the problem is. You may need from exho statements in the scripts to see how far it's getting.

karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bbk



Joined: 15 Oct 2005
Posts: 79

PostPosted: Sun Dec 24, 2006 3:09 pm    Post subject: thank you Reply with quote

thank you very much... that did it!!

here is the working startscript:


streamtranscoder1start.sh
Code:

#!/bin/sh

cd /usr/local/streamtranscoder/
/usr/local/bin/streamTranscoder -c /usr/local/streamtranscoder/streamtranscoder1.conf 1>/dev/null &
sleep 10
echo $! > /usr/local/streamtranscoder/pid/streamtranscoder1.pid



yes i do a transcoding from a livestream to a other quality, both streams (lofi + hifi) have a (seperate) fallback.

the problem was when i disconnect the livestream it will start the fallback then it transcodes the fallback stream, which is unnessecary for me and each time i reconnect to the mountpoint with a source it starts a new transcode process.

somehow i don't know why it didn't work with ps/grep/awk... but with echo$! it works.

thank you
_________________
::bbk::

http://audioasyl.net
Back to top
View user's profile Send private message Visit poster's website
bbk



Joined: 15 Oct 2005
Posts: 79

PostPosted: Tue Feb 13, 2007 12:40 pm    Post subject: pid of streamtranscoder Reply with quote

hello

unfortunatly it does not always (just sometimes) write the pid into the file.

i need to stop the transcoding after the stream stopped so is there a other way to get the pid file on my freebsd for the streamtranscoder?

or does anyone have a other idea?

thx
_________________
::bbk::

http://audioasyl.net
Back to top
View user's profile Send private message Visit poster's website
karlH
Code Warrior
Code Warrior


Joined: 13 Jun 2005
Posts: 5476
Location: UK

PostPosted: Tue Feb 13, 2007 3:28 pm    Post subject: Reply with quote

You have to track this further, is it a question of ST dying before the file is written or a problem of actually writing the file?

karl.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bbk



Joined: 15 Oct 2005
Posts: 79

PostPosted: Fri Sep 14, 2007 9:27 am    Post subject: old freebsd version Reply with quote

well... now with freebsd 6.2 it works well.


i think it was a problem with the freebsd 4.* we had.

greetz
_________________
::bbk::

http://audioasyl.net
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Icecast Streaming Media Server Forum Index -> Icecast Server All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
subRebel style by ktauber