I'm working on a project that is highly configurable via environment 
variables.

I'd like a way to get those environment variables into my mod_perl 
processes so that the mod_perl portion of this project can be configured 
the same way as the non mod_perl portions.

I know that I can use PerlSetEnv and PerlPassEnv. I've used these with 
my current configuration and they work. The problem is this: I'd like a 
method to do this flexibly so that when one of my team created a new 
configuration environment variable, they don't need to change two files, 
the environment setup shell script and the httpd.conf file!

All the environment variables begin with the name of our company in 
upper case letters, followed by an underscore character. This code 
prints them all out just perfectly outside of mod_perl:

[tmornini@millenium conf]$ perl

for my $env ( grep /^EWINGZ_/,keys %ENV ) {
   print "$env\n";
}

EWINGZ_DBI_USERNAME
EWINGZ_ERROR_DB
EWINGZ_CODE_BASE
EWINGZ_ASSERT_ASSERTIONS
EWINGZ_LOG_FILE
EWINGZ_LOG_BASE
EWINGZ_LOG_SPREAD_GROUP
EWINGZ_HOST_NAME
EWINGZ_OBJECT_WO
EWINGZ_LOG_UPPER_LEVEL
EWINGZ_SPREAD_NAME
EWINGZ_LOG_OBJECT
EWINGZ_DBI_PASSWORD
EWINGZ_LOG_LOWER_LEVEL
EWINGZ_DBI_DATASOURCE
EWINGZ_OBJECT_PR
EWINGZ_OBJECT_RO
EWINGZ_OBJECT_RW

However, this code doesn't work so well in a <Perl> section in 
httpd.conf:

<Perl>
   open FH,'>/tmp/env.txt';
   for my $env ( grep /^EWINGZ_/,keys %ENV ) {
     push @PerlPassEnv,$env;
     print FH "$env\n";
   }
   print FH "All done\n";
   close FH;
</Perl>

After startup, 1) The environment variables are NOT passed and 2) 
/tmp/env.txt contains a single line:

All done

which means that at startup, these environment variables aren't 
available to Perl sections, either. This does jive with page 423 of the 
Eagle book.

Stas' excellent Guide is somewhat confusing on this subject:

http://perl.apache.org/guide/config.html

To pass all environment variables to the children with a single 
configuration directive, rather than listing each one via PassEnv or 
PerlPassEnv, a <Perl> section could read in a file and:



But this won't work for the same reason as above, namely, the 
environment variables are visible at that time, and I don't want to 
write a Perl script to parse a sh script! :-)

Also, I think that pushing an arrayref into @PerlPassEnv doesn't seem to 
make sense since PerlPassEnv only takes a single argument. Looks like 
this is an error that the line should read:

push @PerlSetEnv, [ $key => $val ];

Or have I been smoking again? :-)

How can I get around this? Thanks for everyone's time and attention!

Configuration:

Server Version: Apache/1.3.20 (Unix) mod_perl/1.26
Server Built: Aug 28 2001 22:53:29

mod_perl.c, mod_log_spread.c, mod_access.c, mod_rewrite.c, mod_info.c, 
mod_status.c, mod_mime.c, http_core.c

Linux version 2.4.2-2 ([EMAIL PROTECTED]) (gcc version 2.96 
20000731 (Red Hat Linux 7.1 2.96-79)) #1 Sun Apr 8 20:41:30 EDT 2001

-- Tom Mornini
-- eWingz Systems, Inc.
-- ICQ 113526784

Reply via email to