[Jifty-commit] jifty branch, plack-rebased, updated. 0aa0bb977d79cd25119c278720811488a1c011ed

Jifty commits jifty-commit at lists.jifty.org
Wed Feb 10 08:17:15 EST 2010


The branch, plack-rebased has been updated
       via  0aa0bb977d79cd25119c278720811488a1c011ed (commit)
      from  a490aa30d877369121f56a6dc5d6f2edbafebd8f (commit)

Summary of changes:
 Makefile.PL                 |    2 +-
 lib/Jifty/Script/FastCGI.pm |   36 ++++++++++++++----------------------
 2 files changed, 15 insertions(+), 23 deletions(-)

- Log -----------------------------------------------------------------
commit 0aa0bb977d79cd25119c278720811488a1c011ed
Author: Chia-liang Kao <clkao at clkao.org>
Date:   Wed Feb 10 21:15:24 2010 +0800

    Make jifty fastcgi work using Plack::Handler::FastCGI.

diff --git a/Makefile.PL b/Makefile.PL
index f4d5b9b..f72a3f7 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -71,7 +71,7 @@ requires('Module::Refresh');
 requires('Module::ScanDeps');
 requires('Object::Declare' => '0.13');
 requires('Params::Validate');
-requires('Plack' => '0.99_01'); # Plack::Loader Plack::Test Plack::Util Plack::Builder Plack::Request
+requires('Plack' => '0.99_01'); # Plack::Loader Plack::Test Plack::Util Plack::Builder Plack::Request Plack::Handler::FastCGI
 requires('Plack::Middleware::Deflater');
 requires('Scalar::Defer' => '0.12');
 requires('Shell::Command');
diff --git a/lib/Jifty/Script/FastCGI.pm b/lib/Jifty/Script/FastCGI.pm
index bbda17b..1250a89 100755
--- a/lib/Jifty/Script/FastCGI.pm
+++ b/lib/Jifty/Script/FastCGI.pm
@@ -5,8 +5,7 @@ use warnings;
 package Jifty::Script::FastCGI;
 use base qw/Jifty::Script/;
 
-use File::Basename;
-use CGI::Fast;
+use Plack::Handler::FCGI;
 
 =head1 NAME
 
@@ -57,6 +56,11 @@ sub options {
 
 =head1 DESCRIPTION
 
+This command is provided for compatibility.  You should probably use
+Plack's fastcgi deployment tools with the C<app.psgi> file come with
+your jifty app.
+
+
 When you're ready to move up to something that can handle the increasing load your
 new world-changing application is generating, you'll need something a bit heavier-duty
 than the pure-perl Jifty standalone server.  C<FastCGI> is what you're looking for.
@@ -125,26 +129,14 @@ sub run {
 
     Jifty->new();
     my $conf = Jifty->config->framework('Web')->{'FastCGI'} || {};
-    $self->{maxrequests} ||= $conf->{MaxRequests};
-
-    my $PATH = $ENV{'PATH'} || '/bin:/usr/bin';
-
-    my $requests = 0;
-    while ( my $cgi = CGI::Fast->new ) {
-        # the whole point of fastcgi requires the env to get reset here..
-        # So we must squash it again
-        $ENV{'PATH'}   = $PATH;
-        $ENV{'SHELL'}  = '/bin/sh' if defined $ENV{'SHELL'};
-        $ENV{'PATH_INFO'}   = $ENV{'SCRIPT_NAME'}
-            if $ENV{'SERVER_SOFTWARE'} =~ /^lighttpd\b/;
-        for (qw(CDPATH ENV IFS)) {
-            $ENV{$_} = '' if (defined $ENV{$_} );
-        }
-        Jifty->handler->handle_request( cgi => $cgi );
-        if ($self->{maxrequests} && ++$requests >= $self->{maxrequests}) {
-            exit 0;
-        }
-    }
+    $self->{maxrequests} ||= $conf->{MaxRequests}; # XXX: make it work
+
+    my $server = Plack::Handler::FCGI->new(
+        nproc  => $conf->{NProc} || 1,
+        detach => 1,
+    );
+
+    $server->run(Jifty->handler->psgi_app);
 }
 
 1;

-----------------------------------------------------------------------


More information about the Jifty-commit mailing list