line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package POE::Component::Supervisor::Supervised::Proc; |
4
|
1
|
|
|
1
|
|
2844
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use POE::Component::Supervisor::Handle::Proc; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use namespace::clean -except => 'meta'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with qw(POE::Component::Supervisor::Supervised); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has '+handle_class' => ( default => "POE::Component::Supervisor::Handle::Proc" ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
__PACKAGE__->_inherit_attributes_from_handle_class; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub is_abnormal_exit { |
17
|
|
|
|
|
|
|
my ( $self, %args ) = @_; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $exit_code = $args{exit_code}; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
return ( defined($exit_code) and $exit_code != 0 ); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
__PACKAGE__ |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
__END__ |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=pod |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 NAME |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
POE::Component::Supervisor::Supervised::Proc - A supervision descriptor for UNIX processes. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 SYNOPSIS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
use POE; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
use POE::Component::Supervisor; |
39
|
|
|
|
|
|
|
use POE::Component::Supervisor::Supervised::Proc; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
POE::Component::Supervisor->new( |
42
|
|
|
|
|
|
|
children => [ |
43
|
|
|
|
|
|
|
POE::Component::Supervisor::Supervised::Proc->new( |
44
|
|
|
|
|
|
|
program => [qw(memcached -m 64)], |
45
|
|
|
|
|
|
|
restart_policy => "permanent", |
46
|
|
|
|
|
|
|
), |
47
|
|
|
|
|
|
|
], |
48
|
|
|
|
|
|
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$poe_kernel->run; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 DESCRIPTION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This is a factory object that creates L<POE::Component::Supervisor::Handle::Proc> objects. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
See also L<POE::Component::Supervisor::Handle::Proc/ATTRIBUTES>, all of the |
59
|
|
|
|
|
|
|
documented attributes that apply to handle creation are borrowed by this class. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=over 4 |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item handle_class |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
The class to instantiate. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Defaults to L<POE::Component::Supervisor::Handle::Proc>. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Note that attributes are inherited only from |
70
|
|
|
|
|
|
|
L<POE::Component::Supervisor::Handle::Proc>. If your handle class requires |
71
|
|
|
|
|
|
|
additional attributes, you must subclass your own C<Supervised> variant. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
The C<_inherit_attributes_from_handle_class> method can then be invoked on your |
74
|
|
|
|
|
|
|
subclass to reinherit all the attributes. Read the source of |
75
|
|
|
|
|
|
|
L<POE::Component::Supervisor::Supervised> for more details. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=back |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 METHODS |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
See also L<POE::Component::Supervisor::Supervised/METHODS>. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=over 4 |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item spawn |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Called by L<POE::Component::Supervisor> when a new instance of the child |
88
|
|
|
|
|
|
|
process should be spawned. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=item is_abnormal_exit |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Used by C<should_restart>. See L<POE::Component::Supervisor::Supervised> for |
93
|
|
|
|
|
|
|
details. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Returns true if the C<exit_code> argument is not equal to 0. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=back |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|