Tidy up dependencies
[catagits/Catalyst-Devel.git] / lib / Catalyst / Restarter / Win32.pm
CommitLineData
2e9609df 1package Catalyst::Restarter::Win32;
2e9609df 2use Moose;
3use Proc::Background;
cf042872 4use namespace::autoclean;
2e9609df 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.
19 my @command = ( $^X, $0, grep { ! /^\-r/ } @ARGV );
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
341;
36ff1319 35
36__END__
37
38=head1 NAME
39
40Catalyst::Restarter::Win32 - Uses Proc::Background to manage process restarts
41
42=head1 DESCRIPTION
43
44This class uses L<Proc::Background>, which in turn uses
45L<Win32::Process>. The new process is run using the same command-line
46as the original script, but without any restart-based options.
47
48This is a big hack, but using forks just does not work on Windows.
49
50=head1 SEE ALSO
51
52L<Catalyst::Restarter>, L<Catalyst>, <File::ChangeNotify>
53
54=head1 AUTHORS
55
56Catalyst Contributors, see Catalyst.pm
57
58=head1 COPYRIGHT
59
60This program is free software, you can redistribute it and/or modify
61it under the same terms as Perl itself.
62
63=cut