X-Git-Url: http://git.shiar.nl/perl/plp/.git/blobdiff_plain/aaf82199178b7ad9117942bafcb45fadc24e1dab..b5e0ee87251670be18b2f2fc128a4be0b25ebfb8:/lib/PLP/Backend/FastCGI.pm diff --git a/lib/PLP/Backend/FastCGI.pm b/lib/PLP/Backend/FastCGI.pm new file mode 100644 index 0000000..8594a85 --- /dev/null +++ b/lib/PLP/Backend/FastCGI.pm @@ -0,0 +1,98 @@ +package PLP::Backend::FastCGI; + +use strict; + +use PLP::Backend::CGI; +use FCGI; +use base 'PLP::Backend::CGI'; + +our $VERSION = '1.01'; + +sub import { + my $self = shift; + $PLP::interface = $self; + my $request = FCGI::Request(); + $SIG{TERM} = sub { + $request->LastCall(); + }; + $SIG{PIPE} = 'IGNORE'; + while ($request->Accept() >= 0) { + $PLP::use_cache = !defined $ENV{PLP_CACHE} || $ENV{PLP_CACHE}; # before it's clean()ed + delete $ENV{PATH_TRANSLATED}; + $self->everything(); + } +} + +1; + +=head1 NAME + +PLP::Backend::FastCGI - FastCGI interface for PLP + +=head1 SYNOPSIS + +=head2 Lighttpd + +Edit the configuration file (usually F) +to enable I (add/outcomment in server.modules), and add: + + fastcgi.server = ( + ".plp" => (( + "bin-path" => "/usr/bin/perl -MPLP::Backend::FastCGI", + "socket" => "/tmp/fcgi-plp.socket", + )), + ) + +=head2 Apache + +You'll need a dispatch script (F is included with PLP). +Example F: + + #!/usr/bin/perl + use PLP::Backend::FastCGI; + +Then enable either I (recommended) or I, and +setup F (in new installs just create F) with: + + + AddHandler fastcgi-script plp + FastCgiWrapper /foo/bar/plp.fcgi + + + + AddHandler fcgid-script plp + FCGIWrapper /foo/bar/plp.fcgi .plp + + +=head1 DESCRIPTION + +This is usually the preferred backend, providing persistent processes +for speeds comparable to L and +reliability closer to L. + +Servers often feature auto-adjusting number of daemons, script timeouts, +and occasional restarts. + +=head2 Configuration directives + +PLP behaviour can be configured by setting environment variables. + +=over 16 + +=item PLP_CACHE + +Sets caching off if false (0 or empty), on otherwise (true or undefined). +When caching, PLP saves your script in memory and doesn't re-read +and re-parse it if it hasn't changed. PLP will use more memory, +but will also run 50% faster. + +=back + +=head1 AUTHOR + +Mischa POSLAWSKY + +=head1 SEE ALSO + +L, L, L +