X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FEngine%2FHTTP%2FRestarter.pm;h=4691cad9902bb3851102ffdf0b2ae7e7924b5adb;hp=0c73ebd991d335d3349555ba0ac6010a0ffc15d3;hb=4090e3bb3fea1a73ac369250e31584d61428b808;hpb=5303e1782e6a92d80eee93c79d2907dd55a01821 diff --git a/lib/Catalyst/Engine/HTTP/Restarter.pm b/lib/Catalyst/Engine/HTTP/Restarter.pm index 0c73ebd..4691cad 100644 --- a/lib/Catalyst/Engine/HTTP/Restarter.pm +++ b/lib/Catalyst/Engine/HTTP/Restarter.pm @@ -1,31 +1,29 @@ package Catalyst::Engine::HTTP::Restarter; -use strict; -use warnings; -use base 'Catalyst::Engine::HTTP'; +use Moose; +extends 'Catalyst::Engine::HTTP'; + use Catalyst::Engine::HTTP::Restarter::Watcher; -use NEXT; -sub run { +around run => sub { + my $orig = shift; my ( $self, $class, $port, $host, $options ) = @_; $options ||= {}; - die "Sorry, but 'restart' doesn't work together with 'fork'.\n" - if $options->{fork}; - # Setup restarter - my $restarter; - my $parent = $$; - - unless ( $restarter = fork ) { + unless ( my $restarter = fork ) { # Prepare close STDIN; close STDOUT; my $watcher = Catalyst::Engine::HTTP::Restarter::Watcher->new( - directory => File::Spec->catdir( $FindBin::Bin, '..' ), + directory => ( + $options->{restart_directory} || + File::Spec->catdir( $FindBin::Bin, '..' ) + ), + follow_symlinks => $options->{follow_symlinks}, regex => $options->{restart_regex}, delay => $options->{restart_delay}, ); @@ -57,7 +55,7 @@ sub run { # build the Kill request my $req = - HTTP::Request->new( 'KILL', '/', + HTTP::Request->new( 'RESTART', '/', HTTP::Headers->new( 'Connection' => 'close' ) ); $req->protocol('HTTP/1.0'); @@ -69,8 +67,9 @@ sub run { } } - return $self->NEXT::run( $class, $port, $host, $options ); -} + return $self->$orig( $class, $port, $host, $options ); + no Moose; +}; 1; __END__ @@ -90,11 +89,7 @@ and restart the server when any changes are detected. =head1 METHODS -=over 4 - -=item run - -=back +=head2 run =head1 SEE ALSO