Click here to get back home

mod_perl and access to the parent processes environment?

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
mod_perl and access to the parent processes environment? robert 07-19-2006
Get Chitika Premium
Posted by robert on July 19, 2006, 4:41 pm
Please log in for more thread options


So how can I set up the environment prior to launching httpd so that
these values are available in <Perl> stanza's in httpd.conf?

It doesn't look like this is possible.

It looks like the only thing I can do is say

-Ddefinesomething

and then in httpd.conf

ifdefined definesomething
do something

but I need to do more than this.

I want to be able to pass information from the script that launches
httpd and have that information available within a <Perl> stanza.


Posted by Big and Blue on July 19, 2006, 8:09 pm
Please log in for more thread options


robert@elastica.com wrote:
> So how can I set up the environment prior to launching httpd so that
> these values are available in <Perl> stanza's in httpd.conf?

Set an environment variable then access it via %ENV?

> I want to be able to pass information from the script that launches
> httpd and have that information available within a <Perl> stanza.

You could also, of course, just include a file into httpd.conf which has
the relevant values set. If necessary this included file could be created
with the relevant values added in dynamically by the startup script.



--
Just because I've written it doesn't mean that
either you or I have to believe it.

Posted by Mumia W. on July 20, 2006, 7:23 am
Please log in for more thread options


On 07/19/2006 07:09 PM, Big and Blue wrote:
> robert@elastica.com wrote:
>> So how can I set up the environment prior to launching
>> httpd so that these values are available in <Perl>
>> stanza's in httpd.conf?
>
> Set an environment variable then access it via %ENV?
>
>> I want to be able to pass information from the script
>> that launches httpd and have that information available
>> within a <Perl> stanza.
>
> You could also, of course, just include a file into
> httpd.conf which has the relevant values set. If necessary
> this included file could be created with the relevant
> values added in dynamically by the startup script.
>

That won't work out well because the server would have to be
restarted.

Robert, instead I suggest you modify an .htaccess file
instead. Htaccess files are re-read on each access. However, I
doubt you need to do this. Probably anything you can do in a
<Perl> section of an Apache config file can also be done in a
custom perl-handler.

HTH

Posted by Big and Blue on July 20, 2006, 7:22 pm
Please log in for more thread options


Mumia W. wrote:
>
> That won't work out well because the server would have to be
> restarted.

The original question was:

>> So how can I set up the environment prior to launching
>> httpd.

"prior to launching" indicates to me that this is a one-off setting at
startup.

--
Just because I've written it doesn't mean that
either you or I have to believe it.

Posted by robert.nicholson on July 22, 2006, 2:15 am
Please log in for more thread options


Yes the general idea is that I set the environment up with the host
specific info or at the very least hostname of the server i'm starting
and then pull that out of %ENV later. Now I know I can use
getbyhostname in a <perl> block but I wanted to know if my <Perl>
stanza should be able to pull out of %ENV anything that I've
PerlPassEnv'd. Because when I tried this it doesn't work.

Right now I have the startup script process a dictionary and uses
Tempate Toolkit to generate the configuration files upon startup. It's
a very flexible approach but I wanted to know if the above approach was
possible because I wanted another solution instead of relying on
statically generated configuration files.. Strictly speaking they are
dynamic but I was trying to come up with a solution that could reuse
the same httpd.conf across all servers. I just need to have port,
hostname amongst other things. (assume port could vary across servers,
unlikely though)

That said I find a solution where I can pass thru environment vars when
I start httpd and to then evaluate those vars quite simple and elegant
for my needs. Despite the fact that I've invested some time in coding
the existing template based generation approach.

1. I want to setenv VAR some value and I use PerlPassEnv in http.conf
should I then be able to find $VAR in %ENV in any <Perl> stanza? Or is
PerlPassEnv only used to pass thru variables to perl handlers for
request processing with mod perl?


Big and Blue wrote:
> Mumia W. wrote:
> >
> > That won't work out well because the server would have to be
> > restarted.
>
> The original question was:
>
> >> So how can I set up the environment prior to launching
> >> httpd.
>
> "prior to launching" indicates to me that this is a one-off setting at
> startup.
>
> --
> Just because I've written it doesn't mean that
> either you or I have to believe it.


Similar ThreadsPosted
CGI.pm and ModPerl::Registry December 21, 2007, 11:20 pm
modperl and apache handlers December 28, 2004, 5:38 am
CPAN conflict issue - CGI.pm vs ModPerl::Registry September 25, 2006, 12:42 pm
Passing a DBI connection between [Unix] processes January 7, 2005, 1:01 pm
Killing all the child processes created through Expect module December 9, 2004, 4:58 am
modulespath via environment-variable ? February 21, 2005, 2:19 am
how to install/use MP3::Tag in Windows environment? February 6, 2007, 6:57 pm
exporting Environment variables from mod_perl October 23, 2008, 6:44 pm
Is there a way to find a complied net:ssh2 module for ms windows environment September 18, 2007, 1:48 pm
Is there a way to find a complied net:ssh2 module for ms windows environment September 18, 2007, 1:48 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap