> >>>>> "Stas" == Stas Bekman <[EMAIL PROTECTED]> writes:
>
> Stas> Apache::StatINC is perfect for development stage, if you need the same
> Stas> behavior for just a few files on production server, see:
> Stas> http://perl.apache.org/guide/porting.html#Reloading_Modules_and_Required_F
>
> I don't know if this is in your guide, but I stopped using StatINC a
> while ago when it kept stat'ing all over creation for every request,
But it's OK for development server, I don't feel the overhead, do you?
Or did you use StatINC on your production box?
> and then never quite got the re-import right.
Randal, it would help immensely if you could explain about what happens
with exported symbols when module gets reloaded. I understand that they
just stay untouched since StatINC doesn't call import, because it doesn't
know what to import. and there is no 'reset' call or something that flash
the namespace called, so why should be any problem with re-import?
I understand that you are talking about the case where you modify a module
and add a new symbol to be exported. The symbol wouldn't be imported with
StatINC. Otherwise there shouldn't be any problem.
If my understanding is correct, your observation is correct and I'll add
it to the guide. But at large, how much symbols do you add to the export
list? It happens very rarely, IMHO.
> Instead, any module that I'm likely to change during the current server
> restart, I add this:
>
> sub handler { # the beginning of the request
> use Stonehenge::Reload; goto &handler if Stonehenge::Reload->reload_me;
> ...
> }
> When I'm finally done tweaking the module, I remove the line, and it
> reloads one last time, never to watch the file again.
>
> Here's Stonehenge::Reload:
I don't see where you actually pass the list of symbols to be reimported?
Actually what we have here is a StatINC code that forced to be executed on
the module you develop and not for all loaded modules. Did I miss
something?
>
> package Stonehenge::Reload;
>
> use vars qw($VERSION);
> $VERSION = (qw$Revision: 1.1 $ )[-1];
>
> use Apache::Log;
>
> my %mtime;
>
> sub reload_me {
> goto &reload_me if &_reload_caller; # test myself first
> goto &_reload_caller; # now test for caller
> }
>
> sub _reload_caller {
> my $file = (caller)[1];
>
> ## Apache->server->log->notice("$$ is testing $file with $mtime{$file}");
>
> return 0 if exists $mtime{$file} and $mtime{$file} == -M $file;
> ## Apache->server->log->notice("$$ is recompiling $file");
> delete @INC{grep $INC{$_} eq $file, keys %INC};
> my $old = \&{(caller(1))[3]};
> do $file;
> my $new = \&{(caller(1))[3]};
> ## Apache->server->log->notice("$$ got $old => $new for $file");
> return 0 if $old == $new; # safety
> $mtime{$file} = -M $file;
> return 1;
> }
>
> sub import {
> my $file = (caller)[1];
> ## Apache->server->log->notice("$$ is importing ",__PACKAGE__," into $file");
> $mtime{$file} = -M $file;
> }
>
> BEGIN {
> __PACKAGE__->import; # for self reload watching
> };
>
> 1;
>
>
>
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
> <[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
> See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
>
_______________________________________________________________________
Stas Bekman mailto:[EMAIL PROTECTED] http://www.stason.org/stas
Perl,CGI,Apache,Linux,Web,Java,PC http://www.stason.org/stas/TULARC
perl.apache.org modperl.sourcegarden.org perlmonth.com perl.org
single o-> + single o-+ = singlesheaven http://www.singlesheaven.com