Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- I Don't Want to Restart Apache
November 2, 2005, 8:14 am
rate this thread
I'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
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
"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
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:
Deny from All
Allow from localhost
PerlSetVar StatusOptionsAll On
PerlSetVar StatusDumper On
Deny from All
Allow from localhost
<VirtualHost [my ip]:80>
PerlSetVar ReloadAll Off
PerlSetVar ReloadTouchFile /tmp/reload_modules
PerlSetVar ReloadDebug On
RewriteCond % ^it\.t-mark\.co\.jp
RewriteCond % !^/cgi-bin-reg.*
RewriteCond % !^/html.*
RewriteCond % !^/items.*
RewriteCond % !^$
http://it.t-mark.co.jp:80/cgi-bin-reg/search.cgi?subsite =$1 [L,R]
Re: I Don't Want to Restart Apache
A followup to my earlier post.
I've been reading a bit about Multi-Processing Module for Apache and
wondering if this has been causing the problems. From the
Apache::Reload manpage, I've found that it has this to say about memory
usage and syntax trees:
"If you use Apache::Reload with a threaded MPM and multiple Perl
interpreters, the modules will be reloaded by each interpreter as they
are used, not every interpreters at once. Similar to mod_perl 1.0 where
each child has its own Perl interpreter, the modules are reloaded as
each child is hit with a request."
"If a module is loaded at startup, the syntax tree of each subroutine
is shared between interpreters (big win), but each subroutine has its
own padlist (where lexical my variables are stored). Once
Apache::Reload reloads a module, this sharing goes away and each Perl
interpreter will have its own copy of the syntax tree for the reloaded
On this page they also give an example similar to the one we've been
experiencing, but the solution listed doesn't seem work for us.
I'm also confused as to what this particular solution means:
"Solution 1: replace use() with an explicit require() + import().
- use My::Utils;
+ require My::Utils; My::Utils->import();
now the changed functions will be reimported on every request."
Would this make a script running under ModPerl::Registry run like I was
using ModPerl::PerlRun instead?
- » Apache::DBI + mod_perl 2.0.1. Please, help! Cannot get it work!
- — Next thread in » PERL Modules Announcements