Recipe 21.14 Reloading Changed Modules

21.14.1 Problem

You've updated your mod_perl modules, but you have to restart the web server for Apache to notice the change.

21.14.2 Solution

Use Apache::StatINC (standard with mod_perl) to automatically reload any code when it changes on disk:

PerlModule Apache::StatINC PerlInitHandler Apache::StatINC

Or use the CPAN module Apache::Reload to limit the monitoring to specific modules:

PerlModule Apache::Reload PerlInitHandler Apache::Reload PerlSetVar ReloadAll Off PerlSetVar ReloadModules "Example::One Example::Two Example::Three"

21.14.3 Discussion

Apache::Reload includes the functionality of Apache::StatINC. Simply saying:

PerlModule Apache::Reload PerlInitHandler Apache::Reload

is enough to duplicate the functionality of Apache::StatINC. That is, at the start of each request, Apache::Reload goes through all currently loaded modules, checking timestamps to see which have changed. Because checking every module on every request is a burden on popular sites, Apache::Reload also lets you specify which modules to check and reload.

21.14.4 See Also

The documentation for the Apache::StatINC and Apache::Reload modules; Recipe 8.1 in mod_perl Developer's Cookbook; the mod_perl guide at http://perl.apache.org/guide



Perl Cookbook
Perl Cookbook, Second Edition
ISBN: 0596003137
EAN: 2147483647
Year: 2003
Pages: 501

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net