You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Justin Luster <ju...@sawtoothsoftware.com> on 2005/08/17 19:51:41 UTC

Clear Registry

Is there a way in Perl code to clear out the cached code in the
registry?


Re: Clear Registry

Posted by Boysenberry Payne <bo...@humaniteque.com>.
Guess that doesn't help with Apache2, sorry should have looked closer :(


Boysenberry

boysenberrys.com | habitatlife.com | selfgnosis.com

On Aug 17, 2005, at 4:44 PM, Boysenberry Payne wrote:

> I use Apache::StatINC
> It works fine for me, I haven't noticed needing to restart with it
>
> Boysenberry
>
> boysenberrys.com | habitatlife.com | selfgnosis.com
>
> On Aug 17, 2005, at 4:33 PM, Philip M. Gollucci wrote:
>
>> Justin Luster wrote:
>>> So are you saying that a graceful restart is the only real answer?
>>> I've noticed, when doing a lot of development, that Apache::Reload  
>>> doesn't always work when it picks up the change.  I end up getting  
>>> something I needed undefined in another module or something odd like 
>>>  that, and end up with a graceful restart
>> 99.9% of the time Apache2::Reload works well for me; though, I agree 
>> with jonathan, *sometimes*, I do have to restart -- though very 
>> infrequently.
>>
>>
>>
>> -- 
>> END
>> ------------------------------------------------------------
>>     What doesn't kill us can only make us stronger.
>>                 Nothing is impossible.
>> 				
>> Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
>> Consultant / http://p6m7g8.net/Resume/
>> Senior Developer / Liquidity Services, Inc.
>>   http://www.liquidityservicesinc.com
>>        http://www.liquidation.com
>>        http://www.uksurplus.com
>>        http://www.govliquidation.com
>>        http://www.gowholesale.com
>>
>>
>>
>
>
>


Re: Clear Registry

Posted by Badai Aqrandista <ba...@hotmail.com>.
>I use Apache::StatINC
>It works fine for me, I haven't noticed needing to restart with it

Except you have two modules A and B, where A's BEGIN block depends on B's 
BEGIN block being executed beforehand, and you only change module A. In that 
case you definitely must restart.

Got bitten by that on the last project...

Cheers...

---
Badai Aqrandista
Cheepy (?)

_________________________________________________________________
Low rate ANZ MasterCard. Apply now! 
http://clk.atdmt.com/MAU/go/msnnkanz0030000006mau/direct/01/  Must be over 
18 years.


Re: Clear Registry

Posted by Boysenberry Payne <bo...@humaniteque.com>.
I use Apache::StatINC
It works fine for me, I haven't noticed needing to restart with it

Boysenberry

boysenberrys.com | habitatlife.com | selfgnosis.com

On Aug 17, 2005, at 4:33 PM, Philip M. Gollucci wrote:

> Justin Luster wrote:
>> So are you saying that a graceful restart is the only real answer?
>> I've noticed, when doing a lot of development, that Apache::Reload  
>> doesn't always work when it picks up the change.  I end up getting  
>> something I needed undefined in another module or something odd like  
>> that, and end up with a graceful restart
> 99.9% of the time Apache2::Reload works well for me; though, I agree 
> with jonathan, *sometimes*, I do have to restart -- though very 
> infrequently.
>
>
>
> -- 
> END
> ------------------------------------------------------------
>     What doesn't kill us can only make us stronger.
>                 Nothing is impossible.
> 				
> Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
> Consultant / http://p6m7g8.net/Resume/
> Senior Developer / Liquidity Services, Inc.
>   http://www.liquidityservicesinc.com
>        http://www.liquidation.com
>        http://www.uksurplus.com
>        http://www.govliquidation.com
>        http://www.gowholesale.com
>
>
>


Re: Clear Registry

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Justin Luster wrote:
> So are you saying that a graceful restart is the only real answer?
> 
> I've noticed, when doing a lot of development, that Apache::Reload  
> doesn't always work when it picks up the change.  I end up getting  
> something I needed undefined in another module or something odd like  
> that, and end up with a graceful restart
99.9% of the time Apache2::Reload works well for me; though, I agree 
with jonathan, *sometimes*, I do have to restart -- though very 
infrequently.



-- 
END
------------------------------------------------------------
     What doesn't kill us can only make us stronger.
                 Nothing is impossible.
				
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/
Senior Developer / Liquidity Services, Inc.
   http://www.liquidityservicesinc.com
        http://www.liquidation.com
        http://www.uksurplus.com
        http://www.govliquidation.com
        http://www.gowholesale.com


RE: Clear Registry

Posted by Justin Luster <ju...@sawtoothsoftware.com>.
So are you saying that a graceful restart is the only real answer?

-----Original Message-----
From: Jonathan Vanasco [mailto:jvanasco@mastersofbranding.com] 
Sent: Wednesday, August 17, 2005 2:23 PM
To: mod_perl List
Subject: Re: Clear Registry


I've noticed, when doing a lot of development, that Apache::Reload  
doesn't always work when it picks up the change.  I end up getting  
something I needed undefined in another module or something odd like  
that, and end up with a graceful restart

On Aug 17, 2005, at 4:36 PM, Philip M. Gollucci wrote:

> Justin Luster wrote:
>> No I was not using Modperl::RegistryCooker.  I guess I will have to
>> "use" it.
>> In Mod_Perl my "library" files get loaded into memory.  If I want to
>> make a change to the "library" file (one that my main.pl file
>> "requires") I cannot since it is in memory or cache.  To get it to
>> realize the update I usually have to reset Apache.  I'm hoping for an
>> easier way especially since sometimes I don't have the right to reset
>> the server.
> Why not Apache2::Reload
> http://perl.apache.org/docs/2.0/user/coding/ 
> coding.html#Auto_Reloading_Modified_Modules_with_Apache2__Reload



Re: Clear Registry

Posted by Jonathan Vanasco <jv...@mastersofbranding.com>.
I've noticed, when doing a lot of development, that Apache::Reload  
doesn't always work when it picks up the change.  I end up getting  
something I needed undefined in another module or something odd like  
that, and end up with a graceful restart

On Aug 17, 2005, at 4:36 PM, Philip M. Gollucci wrote:

> Justin Luster wrote:
>> No I was not using Modperl::RegistryCooker.  I guess I will have to
>> "use" it.
>> In Mod_Perl my "library" files get loaded into memory.  If I want to
>> make a change to the "library" file (one that my main.pl file
>> "requires") I cannot since it is in memory or cache.  To get it to
>> realize the update I usually have to reset Apache.  I'm hoping for an
>> easier way especially since sometimes I don't have the right to reset
>> the server.
> Why not Apache2::Reload
> http://perl.apache.org/docs/2.0/user/coding/ 
> coding.html#Auto_Reloading_Modified_Modules_with_Apache2__Reload


Re: Clear Registry

Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.
Philip M. Gollucci wrote:
> Justin Luster wrote:
> 
>> No I was not using Modperl::RegistryCooker.  I guess I will have to
>> "use" it.
>>
>> In Mod_Perl my "library" files get loaded into memory.  If I want to
>> make a change to the "library" file (one that my main.pl file
>> "requires") I cannot since it is in memory or cache.  To get it to
>> realize the update I usually have to reset Apache.  I'm hoping for an
>> easier way especially since sometimes I don't have the right to reset
>> the server.
> 
> Why not Apache2::Reload
> http://perl.apache.org/docs/2.0/user/coding/coding.html#Auto_Reloading_Modified_Modules_with_Apache2__Reload

Or for more manual control:

ModPerl::Util::unload_package("My::Library");
require My::Library;

http://perl.apache.org/docs/2.0/api/ModPerl/Util.html#C_unload_package_

--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5

Re: Clear Registry

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Justin Luster wrote:
> No I was not using Modperl::RegistryCooker.  I guess I will have to
> "use" it.
> 
> In Mod_Perl my "library" files get loaded into memory.  If I want to
> make a change to the "library" file (one that my main.pl file
> "requires") I cannot since it is in memory or cache.  To get it to
> realize the update I usually have to reset Apache.  I'm hoping for an
> easier way especially since sometimes I don't have the right to reset
> the server.
Why not Apache2::Reload
http://perl.apache.org/docs/2.0/user/coding/coding.html#Auto_Reloading_Modified_Modules_with_Apache2__Reload

-- 
END
------------------------------------------------------------
     What doesn't kill us can only make us stronger.
                 Nothing is impossible.
				
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/
Senior Developer / Liquidity Services, Inc.
   http://www.liquidityservicesinc.com
        http://www.liquidation.com
        http://www.uksurplus.com
        http://www.govliquidation.com
        http://www.gowholesale.com


RE: Clear Registry

Posted by Justin Luster <ju...@sawtoothsoftware.com>.
No I was not using Modperl::RegistryCooker.  I guess I will have to
"use" it.

In Mod_Perl my "library" files get loaded into memory.  If I want to
make a change to the "library" file (one that my main.pl file
"requires") I cannot since it is in memory or cache.  To get it to
realize the update I usually have to reset Apache.  I'm hoping for an
easier way especially since sometimes I don't have the right to reset
the server.

Thanks,

Justin

-----Original Message-----
From: Philippe M. Chiasson [mailto:gozer@ectoplasm.org] 
Sent: Wednesday, August 17, 2005 1:03 PM
To: Justin Luster
Cc: 'Philip M. Gollucci'; modperl@perl.apache.org
Subject: Re: Clear Registry

Justin Luster wrote:
> I tried this and I get:
> 
> Can't locate object method: "cache_table_common".

Are you calling it as Modperl::RegistryCooker->uncache_myself()?

What is the _exact_ error message ?

But more interestingly, what exactly are you triyng to do that
requires you to clean the cached registry code yourself ?

------------------------------------------------------------------------
--------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID :
88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107
88C3A5A5



Re: Clear Registry

Posted by "Philippe M. Chiasson" <go...@ectoplasm.org>.
Justin Luster wrote:
> I tried this and I get:
> 
> Can't locate object method: "cache_table_common".

Are you calling it as Modperl::RegistryCooker->uncache_myself()?

What is the _exact_ error message ?

But more interestingly, what exactly are you triyng to do that
requires you to clean the cached registry code yourself ?

--------------------------------------------------------------------------------
Philippe M. Chiasson m/gozer\@(apache|cpan|ectoplasm)\.org/ GPG KeyID : 88C3A5A5
http://gozer.ectoplasm.org/     F9BF E0C2 480E 7680 1AE5 3631 CB32 A107 88C3A5A5

RE: Clear Registry

Posted by Justin Luster <ju...@sawtoothsoftware.com>.
I tried this and I get:

Can't locate object method: "cache_table_common".

Thanks,

Justin

-----Original Message-----
From: Philip M. Gollucci [mailto:pgollucci@p6m7g8.com] 
Sent: Wednesday, August 17, 2005 11:05 AM
To: Justin Luster
Cc: modperl@perl.apache.org
Subject: Re: Clear Registry

Justin Luster wrote:
> Is there a way in Perl code to clear out the cached code in the
registry?
> 
 From lib/Modperl-Registry/lib/Modperl/RegistryCooker.pm:

########################################################################
#

# this is a function should be called from the registry script, and
# using the caller() method we figure out the package the script was
# compiled into and trying to uncache it.
#
# it's currently used only for testing purposes and not a part of the
# public interface. it expects to find the compiled package in the
# symbol table cache returned by cache_table_common(), if you override
# cache_table() to point to another function, this function will fail.
sub uncache_myself {
     my $package = scalar caller;
     my($class) = __PACKAGE__->cache_table_common();

     unless (defined $class) {
         Apache2->warn("$$: cannot figure out cache symbol table for 
$package");
         return;
     }

     if (exists $class->{$package} && exists $class->{$package}{mtime})
{
         Apache2->warn("$$: uncaching $package\n") if DEBUG & D_COMPILE;
         delete $class->{$package}{mtime};
     }
     else {
         Apache2->warn("$$: cannot find $package in cache");
     }
}


-- 
END
------------------------------------------------------------
     What doesn't kill us can only make us stronger.
                 Nothing is impossible.
				
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/
Senior Developer / Liquidity Services, Inc.
   http://www.liquidityservicesinc.com
        http://www.liquidation.com
        http://www.uksurplus.com
        http://www.govliquidation.com
        http://www.gowholesale.com



Re: Clear Registry

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Justin Luster wrote:
> Is there a way in Perl code to clear out the cached code in the registry?
> 
 From lib/Modperl-Registry/lib/Modperl/RegistryCooker.pm:

#########################################################################

# this is a function should be called from the registry script, and
# using the caller() method we figure out the package the script was
# compiled into and trying to uncache it.
#
# it's currently used only for testing purposes and not a part of the
# public interface. it expects to find the compiled package in the
# symbol table cache returned by cache_table_common(), if you override
# cache_table() to point to another function, this function will fail.
sub uncache_myself {
     my $package = scalar caller;
     my($class) = __PACKAGE__->cache_table_common();

     unless (defined $class) {
         Apache2->warn("$$: cannot figure out cache symbol table for 
$package");
         return;
     }

     if (exists $class->{$package} && exists $class->{$package}{mtime}) {
         Apache2->warn("$$: uncaching $package\n") if DEBUG & D_COMPILE;
         delete $class->{$package}{mtime};
     }
     else {
         Apache2->warn("$$: cannot find $package in cache");
     }
}


-- 
END
------------------------------------------------------------
     What doesn't kill us can only make us stronger.
                 Nothing is impossible.
				
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/
Senior Developer / Liquidity Services, Inc.
   http://www.liquidityservicesinc.com
        http://www.liquidation.com
        http://www.uksurplus.com
        http://www.govliquidation.com
        http://www.gowholesale.com