[Catalyst] Reloading Controllers on a change

chunzi chunzi at perlchina.org
Sat Jul 2 07:18:20 CEST 2005

Matt S Trout 写道:

>On Thu, Jun 30, 2005 at 02:33:50PM +0200, KXCG Maas wrote:
>>Dear Catalyst hackers,
>>    we are playing with Catalyst for a while and doing a project in it. 
>>We noticed when developing using Catalyst in combination with the apache 
>>webserver that we have to restart the server
>>whenever we make a change to a Controller or any other object in the 
>>We tried Apache::Reload but this gives us strange unpredictable behaviour. 
>>Is there any other way we can reload the controllers whenever one changes.
>Module::Refresh may work better - I think there may also be a modified
>version of Apache::Reload.
>Alternatively you could try using the (highly experimental, not recommended
>for production) Apache::Worlds via this snapshot URL:
>Copy the module from lib/ into your @INC somewhere, and then have a
>startup.pl that contains something like
>use Apache::Worlds;
>Apache::Worlds->register_world('keyname', 'cat::app', '/path/to/file');
>and put
>PerlSetVar Apache_Worlds_Key keyname
>PerlHandler Apache::Worlds
>into your apache config in place of "PerlHandler cat::app". Apache::Worlds
>creates a Safe::World compartment and loads the application into that. Then
>each request is passed through into the compartment by Apache::Worlds, and
>whenever /path/to/file is touched Apache::Worlds will drop the compartment
>and reload it.
>WARNING: Only tested, by me, for development work. Works ok on my mod_perl
>under apache 1, may work other places or not as the case may be. PUT THIS
Using Apache::Reload, after code change, the first time raise 500 error, 
and report below, the second time returns the content I expected.

[Sat Jul 02 13:10:01 2005] [error] [client] Not a CODE 
reference at /usr/local/lib/perl5/site_perl/5.8.6/Catalyst.pm line 
138.\nBEGIN failed--compilation aborted at 
/home/chunzi/www/Fooker/lib/Fooker.pm line 4.\nCompilation failed in 
require at /usr/local/lib/perl5/site_perl/5.8.6/mach/Apache2/Reload.pm 
line 158.\n

Using Module::Refresh, after code change, Catalyst raised an error as blow:

Can't undef active subroutine at...

Using Apache::Worlds, and report the error as ( of course, the module 
not tested under apache2+mod_perl2.1 ):

[Sat Jul 02 13:06:38 2005] [error] [client] Can't locate 
object method "dir_config" via package "Apache2::RequestRec" at 
/home/chunzi/www/Fooker/lib/Apache/Worlds.pm line 15.\n

So, What should I do?

More information about the Catalyst mailing list