Linux mediaserver.pid v.s. multiple instances

General discussion about the media server. Feature requests. Hints, tips and tricks.
Locked
gregorv
Posts: 11
Joined: Thu Nov 24, 2011 5:01 pm
AV Hardware: Fritz!Box

Linux mediaserver.pid v.s. multiple instances

Post by gregorv » Sun Dec 11, 2011 4:34 pm

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

User avatar
phibertron
Posts: 1566
Joined: Sun Jan 30, 2011 5:52 pm
AV Hardware: Hardware
========
WHS - HP Ex495
PS3
XBOX 360
iTouch - Gen 2 and Gen 3
PSP - 3000

Encoders
========
Handbrake
x264
ffmpeg
mencoder

Tagging
======
mp3tag

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

Post by phibertron » Mon Dec 12, 2011 6:19 am

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
viewtopic.php?f=2&t=10627
viewtopic.php?f=2&t=9353
viewtopic.php?f=2&t=9408
viewtopic.php?f=2&t=9416
viewtopic.php?f=2&t=9424
viewtopic.php?f=2&t=9364
viewtopic.php?f=2&t=9497

gregorv
Posts: 11
Joined: Thu Nov 24, 2011 5:01 pm
AV Hardware: Fritz!Box

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

Post by gregorv » Mon Dec 12, 2011 5:44 pm

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

User avatar
phibertron
Posts: 1566
Joined: Sun Jan 30, 2011 5:52 pm
AV Hardware: Hardware
========
WHS - HP Ex495
PS3
XBOX 360
iTouch - Gen 2 and Gen 3
PSP - 3000

Encoders
========
Handbrake
x264
ffmpeg
mencoder

Tagging
======
mp3tag

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

Post by phibertron » Tue Dec 13, 2011 6:35 am

@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 =(
viewtopic.php?f=2&t=10627
viewtopic.php?f=2&t=9353
viewtopic.php?f=2&t=9408
viewtopic.php?f=2&t=9416
viewtopic.php?f=2&t=9424
viewtopic.php?f=2&t=9364
viewtopic.php?f=2&t=9497

florain
Posts: 1
Joined: Fri Dec 16, 2011 11:02 am
AV Hardware: ICYBOX NAS 6210, Roku Soundbridge, Smartphone

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

Post by florain » Fri Dec 16, 2011 11:25 am

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

gregorv
Posts: 11
Joined: Thu Nov 24, 2011 5:01 pm
AV Hardware: Fritz!Box

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

Post by gregorv » Sat Dec 17, 2011 5:01 pm

Great - That's it!
Thanks florian

Locked