Jeff Abrahamson on Fri, 17 May 2002 15:40:16 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Apache based applications [mod_perl]


On Mon, May 13, 2002 at 04:08:26PM -0400, Kyle R . Burton wrote:
> For all the Apahce [mod_perl] experts out there.
> 
> I've got some software that runs under Apache/mod_perl.  It loads a small
> configuraiton file at startup.  It loads the file at startup to cut down
> on per-request overhead.  The settings in the configuraiton file are there
> because it's nice to be able to not have them hard-coded in the software
> (log file paths, a uri registry for speical handeling of inbound requests
> to specific uri stubs, and so on).  Some of these settings (the uri registry)
> are updated frequently enough that it would be nice to be able to re-load 
> and re-process the configuration file on demand (by being signaled by the
> user) instead of having to stop/start or restart Apache.  The best solution
> would be for a non-root user to be able to trigger this behavior.
> 
> Due to Apache's multi-process nature, and Perl's purported issues with
> signal handlers, I'm not sure signals are the best solution.  Nor am I
> convinced that monitoring the timestamp of the file is a great idea either.
> Checking the timestamp for every request seems like a waste of resources
> and on a busy system, also seems like it would be a bad way to handle it.

I don't know a mod_perl specific solution. But what I've done in the
past is to have something like this, in pseudo-code:

    if(last_check_time - time() > threshold) {
        if(the file is changed) {
            reload it
        }
    }

If threshold is a minute or a few minutes, you keep the load of
checking quite low, as the time test is extremely fast and light
weight. Usually that's enough responsiveness if you can cope with
maybe being out of sync for the duration of threshold.

-- 
 Jeff

 Jeff Abrahamson  <http://www.purple.com/jeff/>

 The Big Book of Misunderstanding, now in bookstores and on the web:
 <http://www.misunderstanding.net/buystuff.html>

Attachment: pgpzHmqlA4XEb.pgp
Description: PGP signature