Catalyst::Restarter::Forking: clear watcher in child process
[catagits/Catalyst-Devel.git] / lib / Catalyst / Restarter / Win32.pm
CommitLineData
2e9609df 1package Catalyst::Restarter::Win32;
2
3use Moose;
4use Proc::Background;
5
6extends 'Catalyst::Restarter';
7
8has _child => (
9 is => 'rw',
10 isa => 'Proc::Background',
11);
12
13
2e9609df 14sub _fork_and_start {
15 my $self = shift;
16
17 # This is totally hack-tastic, and is probably much slower, but it
18 # does seem to work.
42eabcc6 19 my @command = ( $^X, map("-I$_", @INC), $0, grep { ! /^\-r/ } @{ $self->argv } );
2e9609df 20
21 my $child = Proc::Background->new(@command);
22
23 $self->_child($child);
24}
25
26sub _kill_child {
27 my $self = shift;
28
29 return unless $self->_child;
30
31 $self->_child->die;
32}
33
c5ac9157 34__PACKAGE__->meta->make_immutable;
35
2e9609df 361;
36ff1319 37
38__END__
39
40=head1 NAME
41
42Catalyst::Restarter::Win32 - Uses Proc::Background to manage process restarts
43
44=head1 DESCRIPTION
45
46This class uses L<Proc::Background>, which in turn uses
47L<Win32::Process>. The new process is run using the same command-line
48as the original script, but without any restart-based options.
49
50This is a big hack, but using forks just does not work on Windows.
51
52=head1 SEE ALSO
53
54L<Catalyst::Restarter>, L<Catalyst>, <File::ChangeNotify>
55
56=head1 AUTHORS
57
58Catalyst Contributors, see Catalyst.pm
59
60=head1 COPYRIGHT
61
62This program is free software, you can redistribute it and/or modify
63it under the same terms as Perl itself.
64
65=cut