From 786897765226386174e2dae02a8cee1ec31d053a Mon Sep 17 00:00:00 2001 From: "bryner%brianryner.com" Date: Sat, 30 Aug 2003 03:43:33 +0000 Subject: [PATCH] Page loader updates to work with mod_perl 2.x: - Give example conf file for mod_perl 2 in README.txt - Use RegistryPrefork handler to emulate mod_perl 1.x's chdir() behavior - Add version of RegistryPrefork.pm backported for mod_perl <= 1.99_08 - Don't autoflush output in the middle of sending HTTP headers; it confuses mod_perl's ParseHeaders - Comment out a warn() that's not really needed r=jrgm --- tools/page-loader/README.txt | 34 +++++++++++++++++++++++----- tools/page-loader/RegistryPrefork.pm | 31 +++++++++++++++++++++++++ tools/page-loader/loader.pl | 4 ++-- 3 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 tools/page-loader/RegistryPrefork.pm diff --git a/tools/page-loader/README.txt b/tools/page-loader/README.txt index b038fc91faaf..14cdd40254b1 100644 --- a/tools/page-loader/README.txt +++ b/tools/page-loader/README.txt @@ -91,9 +91,6 @@ for (@modules) { HTML::Tagset, version: 3.03 Digest::MD5, version: 2.24 - I've also heard that installing with Apache 2.x requires a few changes, - although I don't know what they are. If you know, tell jrgm@netscape.com. - 4) There is code to draw a sorted graph of the final results, but I have disabled the place in 'report.pl' where its use would be triggered (look for the comment). This is so that you can run this without having gone @@ -111,8 +108,10 @@ for (@modules) { 'GD::Text' and 'GD::Graph' from the CPAN shell.] 5) To set this up with Apache, create a directory in the cgi-bin for the web - server called e.g. 'page-loader' and then place this in the Apache - httpd.conf file to enable this for mod_perl (and then restart Apache). + server called e.g. 'page-loader'. + +5a) For Apache 1.x/mod_perl 1.x, place this in the Apache httpd.conf file, + and skip to step 5c. --8<-------------------------------------------------------------------- Alias /page-loader/ /var/www/cgi-bin/page-loader/ @@ -124,7 +123,30 @@ Options +ExecCGI --8<-------------------------------------------------------------------- - So, now you can run this as 'http://yourserver.domain.com/page-loader/loader.pl' +5b) If you're using Apache 2.x and mod_perl 1.99/2.x (tested with Red Hat 9), + place this in your perl.conf or httpd.conf: + +--8<-------------------------------------------------------------------- +Alias /page-loader/ /var/www/cgi-bin/page-loader/ + + +SetHandler perl-script +PerlResponseHandler ModPerl::RegistryPrefork +PerlOptions +ParseHeaders +Options +ExecCGI + +--8<-------------------------------------------------------------------- + + If your mod_perl version is less than 1.99_09, then copy RegistryPrefork.pm + to your vendor_perl ModPerl directory (for example, on Red Hat 9, this is + /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/ModPerl). + + If you are using mod_perl 1.99_09 or above, grab RegistryPrefork.pm from + http://perl.apache.org/docs/2.0/user/porting/compat.html#C_Apache__Registry___C_Apache__PerlRun__and_Friends + and copy it to the vendor_perl directory as described above. + +5c) When you're finished, restart Apache. Now you can run this as + 'http://yourserver.domain.com/page-loader/loader.pl' 6) You need to create a subdirectory call 'db' under the 'page-loader' directory. This subdirectory 'db' must be writeable by UID that Apache diff --git a/tools/page-loader/RegistryPrefork.pm b/tools/page-loader/RegistryPrefork.pm new file mode 100644 index 000000000000..fe707929f77b --- /dev/null +++ b/tools/page-loader/RegistryPrefork.pm @@ -0,0 +1,31 @@ +package ModPerl::RegistryPrefork; + +# RegistryPrefork.pm originally from +# http://perl.apache.org/docs/2.0/user/porting/compat.html#Code_Porting +# backported for mod_perl <= 1.99_08 + +use strict; +use warnings FATAL => 'all'; + +our $VERSION = '0.01'; + +use base qw(ModPerl::Registry); + +use File::Basename (); + +use constant FILENAME => 1; + +sub handler : method { + my $class = (@_ >= 2) ? shift : __PACKAGE__; + my $r = shift; + return $class->new($r)->default_handler(); +} + +sub chdir_file { + my $file = @_ == 2 ? $_[1] : $_[0]->[FILENAME]; + my $dir = File::Basename::dirname($file); + chdir $dir or die "Can't chdir to $dir: $!"; +} + +1; +__END__ diff --git a/tools/page-loader/loader.pl b/tools/page-loader/loader.pl index 93504c010a01..9ad114ea3d36 100755 --- a/tools/page-loader/loader.pl +++ b/tools/page-loader/loader.pl @@ -175,7 +175,7 @@ sub outputPage { my $basepath = $pagedata->httpbase; $basepath =~ s/^http:/https:/i if $ENV{SERVER_PORT} == 443; - warn "basepath: $basepath"; + #warn "basepath: $basepath"; $basepath =~ s#^(.*?)(/base/)$#$1/nocache$2# if ($params{nocache}); $hook .= ""; @@ -205,10 +205,10 @@ sub outputPage { $gResponseNow = [gettimeofday]; # for logging { # turn on output autoflush, locally in this block - local $| = 1; print "Set-Cookie: moztest_SomeRandomCookie1=somerandomstring\n"; print "Set-Cookie: moztest_SomeRandomCookie2=somerandomstring\n"; print $contentTypeHeader; + local $| = 1; print $content; }