It turns out the restarter didn't really work on Win32. This checkin
[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
14sub run_and_watch {
15 my $self = shift;
16
17 $self->_fork_and_start;
18
19 return unless $self->_child;
20
21 $self->_restart_on_changes;
22}
23
24sub _fork_and_start {
25 my $self = shift;
26
27 # This is totally hack-tastic, and is probably much slower, but it
28 # does seem to work.
29 my @command = ( $^X, $0, grep { ! /^\-r/ } @ARGV );
30
31 my $child = Proc::Background->new(@command);
32
33 $self->_child($child);
34}
35
36sub _kill_child {
37 my $self = shift;
38
39 return unless $self->_child;
40
41 $self->_child->die;
42}
43
441;