modperl-accessing_a_file_early_in_the_apache_cycle

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



To: Richard Anderson <Richard.Anderson@raycosoft.com>
From: Stas Bekman <stas@stason.org>
Subject: Re: Read file at startup, access data during
request?
Date: Fri, 30 Mar 2001 11:09:50 +0800 (SGT)

On Thu, 29 Mar 2001, Richard Anderson wrote:

> I want to read and parse a file when Apache mod_perl
>starts and have access to the data while my mod_perl
>methods are processing the request.  The most obvious
>approach (to me) is to put the reading/parsing code at the
>beginning of my mod_perl module, outside of my methods, and
>load the data into a package array variable that my methods
>can access during request processing.  However, I want to
>put the pathname of the file (relative to ServerRoot) in
>the httpd.conf file as a PerlSetVar.  I don't see any way
>to access the value of a PerlSetVar until the request
>phase.  In other words, in the module code that runs at
>startup time, I want to do this: 
> 
>  my $file = >$r->server_root_relative($r->dir_config('SharedSecretKeyFile'));
>
>except I don't have the Apache Request object ($r).  Am I
>completely on the wrong track?  Is there some way to access
>a PerlSetVar without the request object?

How about this: httpd.conf:

<Perl>
use My::Preload;
My::Preload::init('SharedSecretKeyFile');
</Perl>

But you can do this as well:

  my $s         = Apache->server;
  my $file      = $s->dir_config('SharedSecretKeyFile');

The former seems simpler to me...

and it's pretty much all in the guide :)

===

the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu