fixed Server
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Script / Server.pm
CommitLineData
0ba6e8aa 1package Catalyst::Script::Server;
2
53b08cf9 3BEGIN {
4 $ENV{CATALYST_ENGINE} ||= 'HTTP';
5 $ENV{CATALYST_SCRIPT_GEN} = 31;
6 require Catalyst::Engine::HTTP;
7}
5b923b0b 8
a3ca4468 9use FindBin qw/$Bin/;
10use lib "$Bin/../lib";
11use Pod::Usage;
12use Moose;
13use Catalyst::Engine::HTTP;
14use namespace::clean -except => [ qw(meta) ];
15
16with 'MooseX::Getopt';
17
615fee7c 18has help => ( isa => 'Bool', is => 'ro', required => 0, default => sub { 0 } );
19has host => ( isa => 'Str', is => 'ro', required => 0, default => sub { "localhost" } );
20has fork => ( isa => 'Bool', is => 'ro', required => 0 );
21has listen => ( isa => 'Int', is => 'ro', required => 0, default => sub{ 3000 } );
22has pidfile => ( isa => 'Str', is => 'ro', required => 0 );
23has keepalive => ( isa => 'Bool', is => 'ro', required => 0, default => sub { 0 } );
24has background => ( isa => 'Bool', is => 'ro', required => 0 );
25has app => ( isa => 'Str', is => 'ro', required => 1 );
26has restart => ( isa => 'Bool', is => 'ro', required => 0 );
27has restart_delay => ( isa => 'Int', is => 'ro', required => 0 );
28has restart_regex => ( isa => 'Str', is => 'ro', required => 0 );
29has follow_symlinks => ( isa => 'Bool', is => 'ro', required => 0 );
a3ca4468 30
31my @argv = @ARGV;
32
33sub run {
34 my $self = shift;
35
36 pod2usage() if $self->help;
37 my $app = $self->app;
38 Class::MOP::load_class($app);
39 $app->run(
40 $self->listen, $self->host,
41 {
42 'fork' => $self->fork,
43 keepalive => $self->keepalive,
44 background => $self->background,
45 pidfile => $self->pidfile,
615fee7c 46 keepalive => $self->keepalive,
47 restart => $self->restart,
48 restart_delay => $self->restart_delay,
49 restart_regex => qr/$self->restart_regex/,
c1c59374 50# FIXME restart_directory => $self->restart_directory,
615fee7c 51 follow_symlinks => $self->follow_symlinks,
a3ca4468 52 }
53 );
54
55}
5b923b0b 56
5b923b0b 57
0ba6e8aa 581;