Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / Catalyst / Restarter / Forking.pm
CommitLineData
3fea05b9 1package Catalyst::Restarter::Forking;
2
3use Moose;
4
5extends 'Catalyst::Restarter';
6
7has _child => (
8 is => 'rw',
9 isa => 'Int',
10);
11
12
13sub _fork_and_start {
14 my $self = shift;
15
16 if ( my $pid = fork ) {
17 $self->_child($pid);
18 }
19 else {
20 $self->start_sub->();
21 }
22}
23
24sub _kill_child {
25 my $self = shift;
26
27 return unless $self->_child;
28
29 return unless kill 0, $self->_child;
30
31 die "Cannot send INT signal to ", $self->_child, ": $!"
32 unless kill 'INT', $self->_child;
33 # If we don't wait for the child to exit, we could attempt to
34 # start a new server before the old one has given up the port it
35 # was listening on.
36 wait;
37}
38
391;
40
41__END__
42
43=head1 NAME
44
45Catalyst::Restarter::Forking - Forks and restarts the child process
46
47=head1 DESCRIPTION
48
49This class forks and runs the server in a child process. When it needs
50to restart, it kills the child and creates a new one.
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