Commit | Line | Data |
2e9609df |
1 | package Catalyst::Restarter::Win32; |
2 | |
3 | use Moose; |
4 | use Proc::Background; |
5 | |
6 | extends 'Catalyst::Restarter'; |
7 | |
8 | has _child => ( |
9 | is => 'rw', |
10 | isa => 'Proc::Background', |
11 | ); |
12 | |
13 | |
2e9609df |
14 | sub _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 | |
26 | sub _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 |
36 | 1; |
36ff1319 |
37 | |
38 | __END__ |
39 | |
40 | =head1 NAME |
41 | |
42 | Catalyst::Restarter::Win32 - Uses Proc::Background to manage process restarts |
43 | |
44 | =head1 DESCRIPTION |
45 | |
46 | This class uses L<Proc::Background>, which in turn uses |
47 | L<Win32::Process>. The new process is run using the same command-line |
48 | as the original script, but without any restart-based options. |
49 | |
50 | This is a big hack, but using forks just does not work on Windows. |
51 | |
52 | =head1 SEE ALSO |
53 | |
54 | L<Catalyst::Restarter>, L<Catalyst>, <File::ChangeNotify> |
55 | |
56 | =head1 AUTHORS |
57 | |
58 | Catalyst Contributors, see Catalyst.pm |
59 | |
60 | =head1 COPYRIGHT |
61 | |
62 | This program is free software, you can redistribute it and/or modify |
63 | it under the same terms as Perl itself. |
64 | |
65 | =cut |