![]() |
Practical mod_perl / HTML Book / | ![]() |
||
![]() |
||||
![]() |
![]() |
|||
![]() |
![]() |
|||
![]() |
||||
|
|
||||
![]() |
![]() |
|||
![]() |
6.8.2.3. Using Apache::Reload |
![]() |
||
![]() |
||||
![]() |
![]() |
![]() |
||
![]() |
||||
Apache::Reload is a newer module that comes as a drop-in replacement for Apache::StatINC. It provides extra functionality and is more flexible.
To make Apache::Reload check all the loaded modules on each request, just add the following line to httpd.conf:
PerlInitHandler Apache::Reload
To reload only specific modules when these get changed, three alternatives are provided: registering the module implicitly, registering the module explicitly, and setting up a dummy file to touch whenever you want the modules reloaded.
To use implicit module registration, turn off the ReloadAll variable, which is on by default:
PerlInitHandler Apache::Reload PerlSetVar ReloadAll Off
and add the following line to every module that you want to be reloaded on change:
use Apache::Reload;
Alternatively, you can explicitly specify modules to be reloaded in httpd.conf:
PerlInitHandler Apache::Reload PerlSetVar ReloadModules "Book::Foo Book::Bar Foo::Bar::Test"
Note that these are split on whitespace, but the module list must be in quotes, or Apache will try to parse the parameter list itself.
You can register groups of modules using the metacharacter *:
PerlSetVar ReloadModules "Foo::* Bar::*"
In the above example, all modules starting with Foo:: and Bar:: will become registered. This feature allows you to assign all the modules in a project using a single pattern.
The third option is to set up a file that you can touch to cause the reloads to be performed:
PerlSetVar ReloadTouchFile /tmp/reload_modules
Now when you're happy with your changes, simply go to the command line and type:
panic% touch /tmp/reload_modules
If you set this, and don't touch the file, the reloads won't happen (regardless of how the modules have been registered).
This feature is very convenient in a production server environment, but compared to a full restart, the benefits of preloaded modules memory-sharing are lost, since each child will get its own copy of the reloaded modules.
Note that Apache::Reload might have a problem with reloading single modules containing multiple packages that all use pseudo-hashes. The solution: don't use pseudo-hashes. Pseudo-hashes will be removed from newer versions of Perl anyway.
Just like with Apache::StatInc, if you have modules loaded from directories that are not in @INC, Apache::Reload will fail to find the files. This is because @INC is reset to its original value even if it gets temporarily modified in the script. The solution is to extend @INC at server startup to include all the directories from which you load files that aren't in the standard @INC paths.
 
Continue to:
mod_perl, modperl, Apache, perl, cgi, html, mod_perl, e-commerce, scalability, free, open source, OSS, apache, squid, high availability, modperl, linux, unix, Web, www, mod_perl, webserver, admin, apache, book, webmaster, tools, modperl, guide, docs, documentation, help, mod_perl, perl, information, apache, script, errata, eric cholet, perl, apache, mod-perl, stas bekman, mod_perl, cool, perl, Apache, performance, speed, choice
![]() |
Other projects to check out: meta-religion.com is for those interested in Religious, Spiritual and Esoteric Phenomena. i-want-a-better.com is a community of people discussing what they would like to be improved in their lives and things they use and interact with. You may also want to find a healer in your area or read articles on variety of topics.