Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

Getting my feet wet with mod_perl 2 and I'm having trouble reliably testing programs
due to the fact that files/modules seem to be reloading only when Apache deems suitable.

What I'm looking for is a way of having Apache completely reload every component of a particular
program when a change is written to disk. Not just the modules - also the program files calling the modules.
A sort of "refresh all" if you will, without having to restart the web server for every simple change.
For example in this simple set-up:
index.pl -> program called on from web
testmod.pm -> module loaded by index.pl containing various subroutines and some configuration variables which have been exported to index.pl

If I write a change to testmod.pm it's seemingly ignored for an undeterminable period.
Using Apache2::Reload however, testmod.pm will be reloaded. Unfortunately, the configuration variables already exported to index.pl are not updated, probably because Apache sees index.pl as being unchanged.

When updating non-mod_perl systems I'm used to making arbitrary changes and seeing the results immediately, and it would make development a lot simpler to have this comfort of "what you see is the current state of the program",
instead of some half in-memory/on disk version when making these incidental changes.


Any suggestions?
  • Comment on Reload all files in mod_perl testing environment

Replies are listed 'Best First'.
Re: Reload all files in mod_perl testing environment
by jau (Hermit) on Sep 10, 2010 at 12:07 UTC

    Set MaxRequestsPerChild to 1 in your httpd.conf.

      Thanks, but that defeats the purpose of using mod_perl.
      It will always reload!

        That's one of the reasons why I prefer FastCGI over mod_perl.

        Additional reasons:

        • FastCGI works with other servers, not just Apache.
        • A broken application can't crash the entire webserver, "only" its FastCGI process.
        • Applications can run under different user accounts.
        • Applications can be managed by daemontools.
        • FastCGI applications can be debugged as simple, single-shot CGIs

        Alexander

        --
        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

        Yes, but we were talking about a testing environment, right?

Re: Reload all files in mod_perl testing environment
by Khen1950fx (Canon) on Sep 10, 2010 at 13:23 UTC
    If you're having problems with reloading, make sure that you use strict; and use warnings;. Under mod_perl, make sure that 'PerlWarn On' is in your httpd.conf.

    As for modules that can help you, I've used Module::Reload::Selective. Its helped me.