fixed Catalyst::Script::Server so app doesn't have to be a cmd line opt
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Script / FastCGI.pm
index 0c1bffd..9ef4f63 100644 (file)
@@ -1,3 +1,41 @@
 package Catalyst::Script::FastCGI;
 
+BEGIN { $ENV{CATALYST_ENGINE} ||= 'FastCGI' }
+use FindBin qw/$Bin/;
+use lib "$Bin/../lib";
+use Pod::Usage;
+use Moose;
+use namespace::autoclean -except => [ qw(meta) ];
+
+with 'MooseX::Getopt';
+
+has help        => ( isa => 'Bool',   is => 'ro', required => 0, default => sub { 0 } );
+has listen      => ( isa => 'Int',    is => 'ro', required => 1 );
+has pidfile     => ( isa => 'Str',    is => 'ro', required => 0 );
+has daemon      => ( isa => 'Bool',   is => 'ro', required => 0, default => sub { 0 } );
+has manager     => ( isa => 'Str',    is => 'ro', required => 0 );
+has keep_stderr => ( isa => 'Bool',   is => 'ro', required => 0 );
+has nproc       => ( isa => 'Int',    is => 'ro', required => 0 );
+has detach      => ( isa => 'Bool',   is => 'ro', required => 0, default => sub { 0 } );
+has app         => ( isa => 'Str',    is => 'ro', required => 1 );
+
+sub run {
+    my $self = shift;
+    
+    pod2usage() if $self->help;
+    my $app = $self->app;
+    Class::MOP::load_class($app);
+    $app->run(
+        $self->listen,
+        {  
+            nproc   => $self->nproc,
+            pidfile => $self->pidfile,
+            manager => $self->manager,
+            detach  => $self->detach,
+            keep_stderr => $self->keep_stderr,
+        }  
+    );
+
+}
+
 1;