Kind of, sort of make the server work, except it doesn't
[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, default => sub { "localhost" } );
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 has restart         => ( isa => 'Bool',   is => 'ro', required => 0 );
22 has restart_delay   => ( isa => 'Int',    is => 'ro', required => 0 );
23 has restart_regex   => ( isa => 'Str',    is => 'ro', required => 0 );
24 has follow_symlinks => ( isa => 'Bool',   is => 'ro', required => 0 );
25
26 my @argv = @ARGV;
27
28 sub run {
29     my $self = shift;
30     
31     pod2usage() if $self->help;
32     my $app = $self->app;
33     Class::MOP::load_class($app);
34     $app->run(
35         $self->listen, $self->host,
36         {  
37            'fork'     => $self->fork,
38            keepalive  => $self->keepalive,
39            background => $self->background,
40            pidfile    => $self->pidfile,
41            keepalive         => $self->keepalive,
42            restart           => $self->restart,
43            restart_delay     => $self->restart_delay,
44            restart_regex     => qr/$self->restart_regex/,
45 # FIXME    restart_directory => $self->restart_directory,
46            follow_symlinks   => $self->follow_symlinks,
47         }  
48     );
49
50 }
51
52
53 1;