You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Stefan Loones <st...@pandava.com> on 2004/05/25 23:16:19 UTC

mp2: starting a new completely separate perl process

Hi all,

First of all sorry if this is not really mod_perl related

I'm looking for the best way to start a new process from a (SetHandler 
modperl) PerlResponseHandler. I don't want the ResponseHandler to wait 
for the new process. So the new process needs to be completely 
independent. The new process will be doing lots of database queries, and 
put the results in a queue (mysql), were it can be read by the next 
apropriate request from the user.

I'm thinking about doing this like :
system("path/to/newprocess.pl data > /dev/null >2>&1 &");

Tests with a newprocess.pl script that only does "sleep(300)" seems to 
act like suspected. The PerlResponseHandler doesn't wait for it, so 
that's ok. It are no child processes, that's also ok. But when I restart 
Apache, these new processes all dissappear, and this means they are not 
really independent.

The questions:
Is this the best way of doing this ?
Can/will this have a negative effect on mod_perl and/or the perfomance 
of mod_perl ?

Thanks for your time,
Regards,
Stef


-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html


Re: mp2: starting a new completely separate perl process

Posted by Stas Bekman <st...@stason.org>.
Stefan Loones wrote:
> Hi all,
> 
> First of all sorry if this is not really mod_perl related
> 
> I'm looking for the best way to start a new process from a (SetHandler 
> modperl) PerlResponseHandler. I don't want the ResponseHandler to wait 
> for the new process. So the new process needs to be completely 
> independent. The new process will be doing lots of database queries, and 
> put the results in a queue (mysql), were it can be read by the next 
> apropriate request from the user.
> 
> I'm thinking about doing this like :
> system("path/to/newprocess.pl data > /dev/null >2>&1 &");
> 
> Tests with a newprocess.pl script that only does "sleep(300)" seems to 
> act like suspected. The PerlResponseHandler doesn't wait for it, so 
> that's ok. It are no child processes, that's also ok. But when I restart 
> Apache, these new processes all dissappear, and this means they are not 
> really independent.
> 
> The questions:
> Is this the best way of doing this ?
> Can/will this have a negative effect on mod_perl and/or the perfomance 
> of mod_perl ?

It's all explained here:
http://perl.apache.org/docs/1.0/guide/performance.html#Forking_and_Executing_Subprocesses_from_mod_perl
Though you may need to make a few small tweaks to adjus to the 2.0 API.

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html