Krist-
NEVER do an apachectl restart under mod_perl .
there's a known memory leak on that -- the master doesn't give up the
memory.
you always want to do a full stop then start.
if you want to do neat stuff with switching up ports, take a look at
nginx. one of the best features ive seen, is its ability to bring up
a 2nd server on port 80 that uses a new config--
so you
nginx_a::80-> apache_a::8000
launch apache_b::8001
nginx_b -> apache_b::8001
( nginx proxies to old & new config )
stop nginx_a
completely seamless, and completely awesome.
On Jun 8, 2007, at 5:12 AM, Krist van Besien wrote:
Hello all,
I use mod_perl's <perl> sections quite intensively so that I can have
one config for all our webservers, and so that I can change some
settings easily using variables. I recently noted however that <perl>
sections are treated differently when doing a restart (httpd -k
restart) than when doing a full stop and then a start.
Let's illustrate this with a snippet form my config:
(I've removed most of the config, and only kept the bits I think
are relevant)
<perl>
if ( $ENV{SWITCH} eq "test" ) {
$backend = "testserver" ;
} elsif ( $ENV{SWITCH} eq "prod" ) {
$backend = "prodserver ;
} else {
$backend = devserver ;
}
$backendurl="http://" . $backend . ":8080/app";
print STDOUT "backend url is $backendurl\n";
push @PerlConfig, split ("\n", <<EOF);
Listen 8080
Listen 443
NameVirtualHost *:80
<VirtualHost *:80>
# define servername and other virtual host directives here.
RewriteRule ^/app/(.*)\$ http://$backendurl/\$1 [P]
</VirtualHost>
EOF
</perl>
The idea is that before I start the apache server I can set an
environment variable "SWITCH" to either "test" "prod" or nothing, and
have the server forward incoming requests to different backends. To
have some feedback I have the server echo what it is going to use as
"bacendurl".
Here is where it starts to get odd.
When I set the environment variable SWITCH to eg. "prod" and start the
webserver it will output the following to the terminal:
"backend url is http://prodserver:8080/app"
and requests are properly proxied to the production server.
So far so good. It is behaving exactly as expected.
When I then set SWITCH to "test" and do a server restart, using
httpd -k restart
I get the following output:
"backend url is http://testserver:8080/app"
but, and this is the odd thing, the server keeps forwarding requests
to the production server. I exepcted it to start redirecting to the
test server.
From the output I get it is obvious that the perl section gets
executed. But it is as if the @perlconfig that is created is ignored
during a restart.
When I do a httpd -k stop followed by a httpd -k start I don't have
this problem. Then everything performs as expected.
Why is this?
Krist
--
[EMAIL PROTECTED]
Bremgarten b. Bern, Switzerland
--
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?
// Jonathan Vanasco
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
| CEO/Founder SyndiClick Networks
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
| FindMeOn.com - The cure for Multiple Web Personality Disorder
| Web Identity Management and 3D Social Networking
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
| RoadSound.com - Tools For Bands, Stuff For Fans
| Collaborative Online Management And Syndication Tools
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -