| 1 |
NAME |
| 2 |
Apache::Reload - Reload changed modules |
| 3 |
|
| 4 |
SYNOPSIS |
| 5 |
In httpd.conf: |
| 6 |
|
| 7 |
PerlInitHandler Apache::Reload |
| 8 |
PerlSetVar ReloadAll Off |
| 9 |
|
| 10 |
Then your module: |
| 11 |
|
| 12 |
package My::Apache::Module; |
| 13 |
|
| 14 |
use Apache::Reload; |
| 15 |
|
| 16 |
sub handler { ... } |
| 17 |
|
| 18 |
1; |
| 19 |
|
| 20 |
DESCRIPTION |
| 21 |
This module is two things. First it is an adaptation of Randal |
| 22 |
Schwartz's Stonehenge::Reload module that attempts to be a |
| 23 |
little more intuitive and makes the usage easier. |
| 24 |
Stonehenge::Reload was written by Randal to make specific |
| 25 |
modules reload themselves when they changed. Unlike |
| 26 |
Apache::StatINC, Stonehenge::Reload only checked the change time |
| 27 |
of modules that registered themselves with Stonehenge::Reload, |
| 28 |
thus reducing stat() calls. Apache::Reload also offers the exact |
| 29 |
same functionality as Apache::StatINC, and is thus designed to |
| 30 |
be a drop-in replacement. Apache::Reload only checks modules |
| 31 |
that register themselves with Apache::Reload if you explicitly |
| 32 |
turn off the StatINC emulation method (see below). Like |
| 33 |
Apache::StatINC, Apache::Reload must be installed as an Init |
| 34 |
Handler. |
| 35 |
|
| 36 |
StatINC Replacement |
| 37 |
|
| 38 |
To use as a StatINC replacement, simply add the following |
| 39 |
configuration to your httpd.conf: |
| 40 |
|
| 41 |
PerlInitHandler Apache::Reload |
| 42 |
|
| 43 |
Register Modules Implicitly |
| 44 |
|
| 45 |
To only reload modules that have registered with Apache::Reload, |
| 46 |
add the following to the httpd.conf: |
| 47 |
|
| 48 |
PerlInitHandler Apache::Reload |
| 49 |
PerlSetVar ReloadAll Off |
| 50 |
# ReloadAll defaults to On |
| 51 |
|
| 52 |
Then any modules with the line: |
| 53 |
|
| 54 |
use Apache::Reload; |
| 55 |
|
| 56 |
Will be reloaded when they change. |
| 57 |
|
| 58 |
Register Modules Explicitly |
| 59 |
|
| 60 |
You can also register modules explicitly in your httpd.conf file |
| 61 |
that you want to be reloaded on change: |
| 62 |
|
| 63 |
PerlInitHandler Apache::Reload |
| 64 |
PerlSetVar ReloadAll Off |
| 65 |
PerlSetVar ReloadModules "My::Foo My::Bar Foo::Bar::Test" |
| 66 |
|
| 67 |
Note that these are split on whitespace, but the module list |
| 68 |
must be in quotes, otherwise Apache tries to parse the parameter |
| 69 |
list. |
| 70 |
|
| 71 |
Special "Touch" File |
| 72 |
|
| 73 |
You can also set a file that you can touch() that causes the |
| 74 |
reloads to be performed. If you set this, and don't touch() the |
| 75 |
file, the reloads don't happen. This can be a great boon in a |
| 76 |
live environment: |
| 77 |
|
| 78 |
PerlSetVar ReloadTouchFile /tmp/reload_modules |
| 79 |
|
| 80 |
Now when you're happy with your changes, simply go to the |
| 81 |
command line and type: |
| 82 |
|
| 83 |
touch /tmp/reload_modules |
| 84 |
|
| 85 |
And your modules will be magically reloaded on the next request. |
| 86 |
This option works in both StatINC emulation mode and the |
| 87 |
registered modules mode. |
| 88 |
|
| 89 |
PSUEDOHASHES |
| 90 |
The short summary of this is: Don't use psuedohashes. Use an |
| 91 |
array with constant indexes. Its faster in the general case, its |
| 92 |
more guaranteed, and generally, it works. |
| 93 |
|
| 94 |
The long summary is that I've done some work to get this working |
| 95 |
with modules that use psuedo hashes, but its still broken in the |
| 96 |
case of a single module that contains multiple packages that all |
| 97 |
use psuedohashes. |
| 98 |
|
| 99 |
So don't do that. |
| 100 |
|
| 101 |
AUTHOR |
| 102 |
Matt Sergeant, [email protected] |
| 103 |
|
| 104 |
MAINTAINERS |
| 105 |
|
| 106 |
the mod_perl developers, [email protected] |
| 107 |
|
| 108 |
SEE ALSO |
| 109 |
Apache::StatINC, Stonehenge::Reload |
| 110 |
|