Page 1 of 1

Linux mediaserver.pid v.s. multiple instances

Posted: Sun Dec 11, 2011 4:34 pm
by gregorv
I set up two instances of TwonkyMediaServer - one ist started without instance parameter, the other one is started with -instance 1. When I start either instance a mediaserver.pid is created in /var/run.
The problem is, when I start the other instance via the shell script, it finds the PID file and stops the already running instance.

Question: is there a way to rename the PID file?
Any other idea ?

Thanks,
Gregor

Re: Linux mediaserver.pid v.s. multiple instances

Posted: Mon Dec 12, 2011 6:19 am
by phibertron
I put a post on this for windows users here

http://twonkyforum.com/viewtopic.php?f=2&t=9408

But the things youll need to take away from it are there to get it to work
Basically you need to create numbered configs/etc for that instance

Re: Linux mediaserver.pid v.s. multiple instances

Posted: Mon Dec 12, 2011 5:44 pm
by gregorv
hi phibertron - the brilliant creator of my favorite threads here !!

Yes, of course I read that and actually that was - beside your other ideas about views - the reason why I started to dig into Twonky a bit deeper. In your thread there is one mention about Linux but no hint about the PID files (if I did not oversee that).

I have two instances of Twonky running and successfully configured on my VU+ Duo (A SAT receiver like the dream box) . All views are working as wanted.
The minor problem is that the shell script to start and stop the Twony process looks for the PID-file. So I cannot start the instances individually. Meanwhile I changed the script to start and stop both instances from one script but still it would be nice to be able to start/stop them independently. But as the PID file name is the same for both instances the script cannot see (from the PID file) which instance to handle. If a instance is started twonkymediaserver simply overwrites a existing PID file so that it always contains the PID of the last started instance.
Apparently it is not possible to specify a name for the PID-file (or a different path).

Thanks,
Gregor

Re: Linux mediaserver.pid v.s. multiple instances

Posted: Tue Dec 13, 2011 6:35 am
by phibertron
@gregorv

Thanks Man
I see you've done your homework =)
Sadly, my linux skills are my worst asset

I imagine that it has to be possible to do.
to have to two installs and a startup script for each
I know there are a few guys in here that skilled in the arts of nix scripts and what not
maybe they can chinme in here and lend a pointer or two

I wish I had a real answer for you =(

Re: Linux mediaserver.pid v.s. multiple instances

Posted: Fri Dec 16, 2011 11:25 am
by florain
Obviously the name of the PID-file is hard-coded in the twonkymedia executable. But I guess I ve found a simple solution for the issue by only adding one line to the start-up-script in twonkymedia.sh.

I use two different script-files, one for each instance. Each file has a different PID-file name and a additional mv command.

twonkymedia_1.sh
[code]
WORKDIR1="/usr/local/twonkymedia"
WORKDIR2="`dirname $0`"
PIDFILE=/var/run/mediaserver_1.pid
OPTION="-inifile /var/twonkymedia_1/twonkymedia_1.ini"

....

echo -n "Starting $TWONKYSRV ... "
"$TWONKYSRV" -D -inifile /var/twonkymedia_1/twonkymedia_1.ini
mv /var/run/mediaserver.pid $PIDFILE
rc_status -v
[/code]

twonkymedia_2.sh
[code]
WORKDIR1="/usr/local/twonkymedia"
WORKDIR2="`dirname $0`"
PIDFILE=/var/run/mediaserver_2.pid
OPTION="-inifile /var/twonkymedia_2/twonkymedia_2.ini"

....

echo -n "Starting $TWONKYSRV ... "
"$TWONKYSRV" -D -inifile /var/twonkymedia_2/twonkymedia_2.ini
mv /var/run/mediaserver.pid $PIDFILE
rc_status -v
[/code]

With this modification the mediaserver.pid is remaned directly after starting the instance to the name given as PIDFILE. Thus all status|restart|stop operations access the right PID-file.

Regards,
Flo

Re: Linux mediaserver.pid v.s. multiple instances

Posted: Sat Dec 17, 2011 5:01 pm
by gregorv
Great - That's it!
Thanks florian