I Don"t Want to Restart Apache
am 02.11.2005 12:14:48 von boujinI'm attempting to use mod_perl for a CGI, CGI::Application, DB-backed
Web site that has been running without mod_perl for more than a year
now. We are overhauling the code and building a new Web site out of
it. However, we have run into caching issues that we haven't been able
to get around other than to restart Apache every time we update the
files.
We will either see no change in the script whatsoever, mod_perl
continues to use the cached script, or we will get a fatal error as
mod_perl crashes and burns when trying to include files that it doesn't
know the location of. (@INC has cleared? not been updated?) If the
script does decide to crash and burn we get an error somewhere along
lines of:
"Can't locate ... .pm" or "Unrecognized method 'new()'", which is
defined in the CGI::Application module. (I wish I had a real error
message for you right now, but the site is just using the cache and not
crashing on me at all at the moment.)
And, of course, a restart of Apache fixes all of this.
We've tried everything we can think of to get the server to recognize
that a file has been modified on the server. This includes:
1. Use Apache::Reload (naturally)
2. Turn off the ReloadAll option
3. Add a touch file to the "tmp" directory
4. Add "use Apache::Reload" to all the files we want to reload when the
timestamp on the touchfile is updated.
5. Touching both the CGI script and the modified PM files. (File
structure is based on the CGI::Application way of doing things.)
Our typical work flow goes like this.
1. Edit file on local machine.
2. Commit the changes to CVS.
3. Do a CVS update on the server to grab the latest version of the
file.
4. Restart Apache.
Since this is still in production, on a stage server, there is no
problem restarting Apache, for now. However, this machine will be the
Live server in the future.
Server / Software Statistics:
- Server version: Apache/2.0.52
- This is perl, v5.8.5 built for i386-linux-thread-multi
- RedHat 4ES
- RPM: mod_perl-2.0.1-1.fc4
- RPM: perl-5.8.5-12.1
Here is an edited version of the httpd.conf file:
PerlSwitches -w
ExtendedStatus On
PerlModule Devel::Symdump
PerlModule Apache2::Status
PerlModule ModPerl::Registry
PerlModule Apache2::Reload
SetHandler server-status
Order Deny,Allow
Deny from All
Allow from localhost
SetHandler perl-script
PerlHandler Apache2::Status
PerlSetVar StatusOptionsAll On
PerlSetVar StatusDumper On
Order Deny,Allow
Deny from All
Allow from localhost
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
Options +ExecCGI
UseCanonicalName Off
VirtualDocumentRoot /var/www/%0/
VirtualScriptAlias /var/www/%0/cgi-bin/
PerlInitHandler Apache2::Reload
PerlSetVar ReloadAll Off
PerlSetVar ReloadTouchFile /tmp/reload_modules
PerlSetVar ReloadDebug On
RewriteEngine On
RewriteLog /var/log/httpd/server.rewrite.txt
RewriteLogLevel 2
RewriteCond %{HTTP_HOST} ^it\.t-mark\.co\.jp
[NC]
RewriteCond %{REQUEST_URI} !^/cgi-bin-reg.*
RewriteCond %{REQUEST_URI} !^/html.*
RewriteCond %{REQUEST_URI} !^/items.*
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/(.*)
http://it.t-mark.co.jp:80/cgi-bin-reg/search.cgi?subsite=$1 [L,R]