I Don"t Want to Restart Apache

I Don"t Want to Restart Apache

am 02.11.2005 12:14:48 von boujin

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
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]

Re: I Don"t Want to Restart Apache

am 03.11.2005 03:02:52 von sss

boujin@gmail.com wrote:
> 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
> files.
>

I have not found a solution to this myself, and will be interetsed in
others responses.

A graceful restart of apache is quite kind to production apps as state
is preserved.

Re: I Don"t Want to Restart Apache

am 03.11.2005 14:11:44 von Arne Sommer

boujin@gmail.com wrote:
> 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
> files.

Take a look at Apache::Reload.


--Arne Sommmer...

Re: I Don"t Want to Restart Apache

am 04.11.2005 02:46:20 von boujin

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
subroutines."

[http://perl.apache.planetmirror.com/docs/2.0/api/Apache/Rel oad.html]

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?