blib/lib/PLP/Backend/FastCGI.pm untested

filter: Statementstmt 0.0% 0 / 26 Branchbran n/a Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 38 CC 1 SCAR 6.9
CC
1
Cov
0%
import
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package PLP::Backend::FastCGI;
2  
3 use strict;
4 use warnings;
5  
6 use PLP::Backend::CGI ();
7 use FCGI;
8 use base 'PLP::Backend::CGI';
9  
10 our $VERSION = '1.01';
11  
12 sub import {
13 my $self = shift;
14 $PLP::interface = $self;
15 my $request = FCGI::Request();
16 $SIG{TERM} = sub {
17 $request->LastCall();
18 };
19 $SIG{PIPE} = 'IGNORE';
20 while ($request->Accept() >= 0) {
21 $PLP::use_cache = !defined $ENV{PLP_CACHE} || $ENV{PLP_CACHE}; # before it's clean()ed
22 delete $ENV{PATH_TRANSLATED};
23 $self->everything();
24 }
25 }
26  
27 1;
28  
29 =head1 NAME
30  
31 PLP::Backend::FastCGI - FastCGI interface for PLP
32  
33 =head1 SYNOPSIS
34  
35 =head2 Lighttpd
36  
37 Add this to your configuration file (usually F</etc/lighttpd/lighttpd.conf>):
38  
39 server.modules += ("mod_fastcgi")
40 fastcgi.server += (".plp" => ((
41 "bin-path" => "/usr/bin/perl -MPLP::Backend::FastCGI",
42 "socket" => "/tmp/fcgi-plp.socket",
43 )))
44 server.indexfiles += ("index.plp")
45 static-file.exclude-extensions += (".plp")
46  
47 =head2 Apache
48  
49 You'll need a dispatch script (F<plp.fcgi> is included with PLP).
50 Example F</foo/bar/plp.fcgi>:
51  
52 #!/usr/bin/perl
53 use PLP::Backend::FastCGI;
54  
55 Then enable either I<mod_fcgid> (recommended) or I<mod_fastcgi>, and
56 setup F<httpd.conf> (in new installs just create F</etc/apache/conf.d/plp>) with:
57  
58 <IfModule mod_fastcgi.c>
59 AddHandler fastcgi-script plp
60 FastCgiWrapper /foo/bar/plp.fcgi
61 </IfModule>
62  
63 <IfModule mod_fcgid.c>
64 AddHandler fcgid-script plp
65 FCGIWrapper /foo/bar/plp.fcgi .plp
66 </IfModule>
67  
68 =head1 DESCRIPTION
69  
70 This is usually the preferred backend, providing persistent processes
71 for speeds comparable to L<mod_perl|PLP::Backend::Apache> and
72 reliability closer to L<CGI|PLP::Backend::CGI>.
73  
74 Servers often feature auto-adjusting number of daemons, script timeouts,
75 and occasional restarts.
76  
77 =head2 Configuration directives
78  
79 PLP behaviour can be configured by setting environment variables.
80  
81 =over 16
82  
83 =item PLP_CACHE
84  
85 Sets caching off if false (0 or empty), on otherwise (true or undefined).
86 When caching, PLP saves your script in memory and doesn't re-read
87 and re-parse it if it hasn't changed. PLP will use more memory,
88 but will also run 50% faster.
89  
90 =back
91  
92 =head1 AUTHOR
93  
94 Mischa POSLAWSKY <perl@shiar.org>
95  
96 =head1 SEE ALSO
97  
98 L<PLP>, L<PLP::Backend::CGI>, L<FCGI>
99