It seems like I've tried everything, and I can't get Apache2::Reload to
reload my modules.
I have a handler in a module called JetSet::Handler. That module
depends on a number of other modules, which I've tried to include with
'use', with limited success. It seems, sometimes, symbols act just fine
and reload when they should, but other times, I have to restart Apache
in order to get the symbols to reload.
I have run the Reload debugger, and it says everything is reloading just
like it should. But, I believe my problem is described in the
Apache2::Reload documentation; Apache keeps the old function pointer
around from the first 'use', even though the changed function now has a
new pointer.
The Apache2::Reload documentation also says Registry (which I'm not
actually explicitly using) doesn't play nicely with Exporter when 'use'
is used, so I tried the 'require';'import()' method described in the
documentation. With this, I'm unable to import my symbols. For example:
# In Handler.pm:
require JetSet::Debug; JetSet::Debug->import();
# ...
JetSet::Debug::DebugLevel(JetSet::Debug::DEBUG_WARN);
# End
Where DEBUG_WARN is declared either by sub DEBUG_WARN() { 3 }; or with
'use constant' in Debug.pm. It is then exported in @EXPORT or
@EXPORT_OK. Any combination of these things gives the following error.
# From error_log:
failed to resolve handler `JetSet::Handler': Bareword
"JetSet::Debug::DEBUG_WARN" not allowed while "strict subs" in use at
/home/cww/sites/rain/htdocs/jet-set/JetSet/Handler.pm line 19.
# End
I read in the list archives that doing away with Exporter altogether
might be the preferred way of dealing with this. Implementing my
modules as objects instead of exporting functions, it seems, might
eliminate the not-exporting errors and make Reload work correctly:
http://www.gossamer-threads.com/lists/modperl/modperl/82283#82283
I'm not opposed to doing that, but in that case, how does one deal with
things like constants? Perhaps I would just have to keep all my
constants in a single Exporter-style file and then restart Apache every
time I change it? Frankly, that sounds like a pretty lousy way to have
to deal with this.
Here are some snippets that might help with the diagnosis.
# From my virtual host configuration:
PerlRequire /home/cww/sites/rain/htdocs/perl-static/startup.pl
PerlModule Apache2::Reload
PerlInitHandler Apache2::Reload
PerlSetVar ReloadDirectories "/home/cww/sites/rain/htdocs"
<Location /jet-set>
SetHandler perl-script
PerlResponseHandler JetSet::Handler
</Location>
# End
# startup.pl:
use lib qw(/home/cww/sites/rain/htdocs/jet-set);
1;
# End
# Apache2 version string:
Apache/2.2.3 (Debian) mod_ssl/2.2.3 OpenSSL/0.9.8e
mod_apreq2-20051231/2.6.0 mod_perl/2.0.2 Perl/v5.8.8 Server at rain Port 80
# End
Thank you for your assistance.
Colin