package Catalyst::Restarter;
+
use Moose;
use Cwd qw( abs_path );
use File::ChangeNotify;
use FindBin;
-use namespace::autoclean;
+use namespace::clean -except => 'meta';
has start_sub => (
is => 'ro',
required => 1,
);
+has argv => (
+ is => 'ro',
+ isa => 'ArrayRef',
+ required => 1,
+);
+
has _watcher => (
is => 'rw',
isa => 'File::ChangeNotify::Watcher',
delete $p->{start_sub};
- $p->{filter} ||= qr/(?:\/|^)(?!\.\#).+(?:\.yml$|\.yaml$|\.conf|\.pm)$/;
+ $p->{filter} ||= qr/(?:\/|^)(?![.#_]).+(?:\.yml$|\.yaml$|\.conf|\.pm)$/;
$p->{directories} ||= abs_path( File::Spec->catdir( $FindBin::Bin, '..' ) );
# We could make this lazily, but this lets us check that we
package Catalyst::Restarter::Forking;
-use Moose;
-use threads;
-use Thread::Cancel;
-use namespace::autoclean;
+use Moose;
extends 'Catalyst::Restarter';
return unless kill 0, $self->_child;
- local $SIG{CHLD} = 'IGNORE';
die "Cannot send INT signal to ", $self->_child, ": $!"
unless kill 'INT', $self->_child;
+ # If we don't wait for the child to exit, we could attempt to
+ # start a new server before the old one has given up the port it
+ # was listening on.
+ wait;
}
1;
package Catalyst::Restarter::Win32;
+
use Moose;
use Proc::Background;
-use namespace::autoclean;
extends 'Catalyst::Restarter';
# This is totally hack-tastic, and is probably much slower, but it
# does seem to work.
- my @command = ( $^X, $0, grep { ! /^\-r/ } @ARGV );
+ my @command = ( $^X, map("-I$_", @INC), $0, grep { ! /^\-r/ } @{ $self->argv } );
my $child = Proc::Background->new(@command);