fixed Server and testapp_server.pl. Test still wonky
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Script / Server.pm
1 package Catalyst::Script::Server;
2
3
4 use FindBin qw/$Bin/;
5 use lib "$Bin/../lib";
6 use Pod::Usage;
7 use Moose;
8 use Catalyst::Engine::HTTP;
9 use namespace::clean -except => [ qw(meta) ];
10
11 with 'MooseX::Getopt';
12
13 has help        => ( isa => 'Bool',   is => 'ro', required => 0, default => sub { 0 } );
14 has host        => ( isa => 'Str',    is => 'ro', required => 0 );
15 has fork        => ( isa => 'Bool',   is => 'ro', required => 0 );
16 has listen      => ( isa => 'Int',    is => 'ro', required => 0, default => sub{ 3000 } );
17 has pidfile     => ( isa => 'Str',    is => 'ro', required => 0 );
18 has keepalive   => ( isa => 'Bool',   is => 'ro', required => 0, default => sub { 0 } );
19 has background  => ( isa => 'Bool',   is => 'ro', required => 0 );
20 has app         => ( isa => 'Str',    is => 'ro', required => 1 );
21
22 my @argv = @ARGV;
23
24 sub run {
25     my $self = shift;
26     
27     pod2usage() if $self->help;
28     my $app = $self->app;
29     Class::MOP::load_class($app);
30     $app->run(
31         $self->listen, $self->host,
32         {  
33            'fork'     => $self->fork,
34            keepalive  => $self->keepalive,
35            background => $self->background,
36            pidfile    => $self->pidfile,
37         }  
38     );
39
40 }
41
42
43 1;