lib/Catalyst/Script/FastCGI.pm

filter: Statementstmt 100% 39 / 39 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 1 totaltotal 98.1% 54 / 55 CC 4 SCAR 5.1
CC
4
Cov
100%
_plack_loader_args
3.0
_listen
2.0
BEGIN
1.0
CRAP 1.7
« lib/Catalyst/ActionContainer.pm ↑ Summary lib/Catalyst/Script/Test.pm »
1 package Catalyst::Script::FastCGI;
2 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use Data::OptList;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use namespace::clean -except => [ 'meta' ];
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 15 ▶sub _plack_engine_name { 'FCGI' }
Subroutine _plack_engine_name: called CC=1 SCAR=0.0
7  
8 2 with 'Catalyst::ScriptRole';
9  
10 2 has listen => (
11 traits => [qw(Getopt)],
12 cmd_aliases => 'l',
13 isa => 'Str',
14 is => 'ro',
15 documentation => 'Specify a listening port/socket',
16 );
17  
18 2 has pidfile => (
19 traits => [qw(Getopt)],
20 cmd_aliases => [qw/pid p/],
21 isa => 'Str',
22 is => 'ro',
23 documentation => 'Specify a pidfile',
24 );
25  
26 2 has daemon => (
27 traits => [qw(Getopt)],
28 isa => 'Bool',
29 is => 'ro',
30 cmd_aliases => [qw/d detach/], # Eww, detach is here as we fucked it up.. Deliberately not documented
31 documentation => 'Daemonize (go into the background)',
32 );
33  
34 2 has manager => (
35 traits => [qw(Getopt)],
36 isa => 'Str',
37 is => 'ro',
38 cmd_aliases => 'M',
39 documentation => 'Use a different FastCGI process manager class',
40 );
41  
42 2 has keeperr => (
43 traits => [qw(Getopt)],
44 cmd_aliases => 'e',
45 isa => 'Bool',
46 is => 'ro',
47 documentation => 'Log STDERR',
48 );
49  
50 2 has nproc => (
51 traits => [qw(Getopt)],
52 cmd_aliases => 'n',
53 isa => 'Int',
54 is => 'ro',
55 documentation => 'Specify a number of child processes',
56 );
57  
58 2 has proc_title => (
59 traits => [qw(Getopt)],
60 isa => 'Str',
61 is => 'ro',
62 lazy => 1,
63 builder => '_build_proc_title',
64 documentation => 'Set the process title',
65 );
66  
67 14 ▶sub _build_proc_title {
Subroutine _build_proc_title: called CC=1 SCAR=0.0
68 14 my ($self) = @_;
69 14 return sprintf 'perl-fcgi-pm [%s]', $self->application_name;
70 }
71  
72 15 ▶sub BUILD {
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
73 15 my ($self) = @_;
74 15 $self->proc_title;
75 }
76  
77 # Munge the 'listen' arg so that Plack::Handler::FCGI will accept it.
78 15 ▶sub _listen {
Subroutine _listen: called CC=2 SCAR=6.9
79 15 my ($self) = @_;
80  
81 15 ▶ if (defined (my $listen = $self->listen)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $listen = $self->listen)) { } 2 13 15
82 2 return [ $listen ];
83 } else {
84 13 return undef;
85 }
86 }
87  
88 15 ▶sub _plack_loader_args {
Subroutine _plack_loader_args: called CC=3 SCAR=11.0
89 15 my ($self) = shift;
90  
91 15 my $opts = Data::OptList::mkopt([
92 qw/manager nproc proc_title/,
93 pid => [ 'pidfile' ],
94 daemonize => [ 'daemon' ],
95 keep_stderr => [ 'keeperr' ],
96 listen => [ '_listen' ],
97 ]);
98  
99 15 ▶ my %args = map { $_->[0] => $self->${ \($_->[1] ? $_->[1]->[0] : $_->[0]) } } @$opts;
Branch: 1 branch
BranchTrueFalseTotal
$_->[1] ? : 60 45 105
100  
101 # Plack::Handler::FCGI thinks manager => undef means "use no manager".
102 15 ▶ delete $args{'manager'} unless defined $args{'manager'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args{"manager"} 13 2 15
103  
104 15 return %args;
105 }
106  
107 15 ▶around _application_args => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
108 15 my ($orig, $self) = @_;
109 return (
110 $self->listen,
111 {
112 15 %{ $self->$orig },
113 nproc => $self->nproc,
114 pidfile => $self->pidfile,
115 manager => $self->manager,
116 detach => $self->daemon,
117 keep_stderr => $self->keeperr,
118 proc_title => $self->proc_title,
119 }
120 );
121 2 };
122  
123 2 __PACKAGE__->meta->make_immutable;
124 2 1;
125  
126 =head1 NAME
127  
128 Catalyst::Script::FastCGI - The FastCGI Catalyst Script
129  
130 =head1 SYNOPSIS
131  
132 myapp_fastcgi.pl [options]
133  
134 Options:
135 -? --help display this help and exits
136 -l --listen Socket path to listen on
137 (defaults to standard input)
138 can be HOST:PORT, :PORT or a
139 filesystem path
140 -n --nproc specify number of processes to keep
141 to serve requests (defaults to 1,
142 requires -listen)
143 -p --pidfile specify filename for pid file
144 (requires -listen)
145 -d --daemon daemonize (requires -listen)
146 -M --manager specify alternate process manager
147 (FCGI::ProcManager sub-class)
148 or empty string to disable
149 -e --keeperr send error messages to STDOUT, not
150 to the webserver
151 --proc_title set the process title
152  
153 =head1 DESCRIPTION
154  
155 Run a Catalyst application as fastcgi.
156  
157 =head1 SEE ALSO
158  
159 L<Catalyst::ScriptRunner>
160  
161 =head1 AUTHORS
162  
163 Catalyst Contributors, see Catalyst.pm
164  
165 =head1 COPYRIGHT
166  
167 This library is free software. You can redistribute it and/or modify it under
168 the same terms as Perl itself.
169  
170 =cut
« lib/Catalyst/ActionContainer.pm ↑ Summary lib/Catalyst/Script/Test.pm »