Best way to generate frontend PID

Help with using MiniMyth's build system

Moderator: Pablo

Post Reply
jamesarbrown
Contributor
Posts: 98
Joined: Sat Aug 16, 2008 11:14 am

Best way to generate frontend PID

Post by jamesarbrown »

Hi,

I need to generate a PID for mythfrontend and happily already minimyth has a way of grabbing the pid which mythfrontend does not.

Code: Select all

mm_command application_pids mythfrontend
Returns as example

Code: Select all

[
2789
]
So was thinking that mm_command x_start, could use this facility to generate say /var/run/mythfrontend.pid, but I have no perl idea how to track down the area of code that is x_start

Any suggestions?

James
jamesarbrown
Contributor
Posts: 98
Joined: Sat Aug 16, 2008 11:14 am

Re: Best way to generate frontend PID

Post by jamesarbrown »

Humm

Found it

Code: Select all

/usr/lib/perl5/site_perl/5.12.2/MiniMyth.pm
Contains the classes.

Now time to learn Perl... nightmare

James
jamesarbrown
Contributor
Posts: 98
Joined: Sat Aug 16, 2008 11:14 am

Re: Best way to generate frontend PID

Post by jamesarbrown »

Well I did find a way....... but not entirely happy.

In the MiniMyth.pm file firstly added the following import

Code: Select all

use Time::HiRes    ('sleep');
and secondly added the following code to x_start

Code: Select all

sleep(10);
my @pids = @{$self->application_pids("mythfrontend")};
unlink("/var/run/mythfrontend.pid");
open (mythfrontendpidFile, '>>/var/run/mythfrontend.pid');
print mythfrontendpidFile "$pids[0]\n";
close (mythfrontendpidFile);
The bit I am not happy about is the sleep function, its a dirty workaround/bodge/shortcut, but without as xinit takes some time, no PID is found.

So I went onto try and create a 100mythpid file in xinitrc.d.... but there I simply could not seem to grab the PID via bash and mm_command (also got empty result).

Anyone have any better suggestions/ideas. Would be nice if MM had some pid file functionality on a perm basis, so with monit can help to keep FE up.

James
Post Reply