[Jifty-commit] r2022 - jifty/trunk/lib/Jifty/Script

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Fri Oct 13 17:13:45 EDT 2006


Author: clkao
Date: Fri Oct 13 17:13:44 2006
New Revision: 2022

Modified:
   jifty/trunk/lib/Jifty/Script/FastCGI.pm

Log:
'jifty fascgi' now supporst --maxrequests and --gladiator.  It also
takes the options from config.


Modified: jifty/trunk/lib/Jifty/Script/FastCGI.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/FastCGI.pm	(original)
+++ jifty/trunk/lib/Jifty/Script/FastCGI.pm	Fri Oct 13 17:13:44 2006
@@ -46,15 +46,37 @@
         )
     )
 
+=head2 options
+
+=cut
+
+sub options {
+    (
+        'requests=i' => 'maxrequests',
+        'gladitator' => 'gladiator'
+    );
+}
+
 =head2 run
 
 Creates a new FastCGI process.
 
 =cut
- 
+
+my $gladiator;
+
+BEGIN {
+    $gladiator = eval { require Devel::Gladiator; 1 };
+}
+
 sub run {
+    my $self = shift;
     Jifty->new();
+    my $conf = Jifty->config->framework('Web')->{'FastCGI'} || {};
+    $self->{maxrequests} ||= $conf->{MaxRequests};
+    $self->{gladiator} ||= $conf->{Gladiator};
 
+    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
@@ -66,6 +88,12 @@
             $ENV{$_} = '' if (defined $ENV{$_} );
         }
         Jifty->handler->handle_request( cgi => $cgi );
+	if ($self->{maxrequests} && ++$requests >= $self->{maxrequests}) {
+	    if ($self->{gladiator} && $gladiator) {
+		Jifty->log->info( Devel::Gladiator::arena_table() );
+	    }
+	    exit 0;
+	}
     }
 }
 


More information about the Jifty-commit mailing list