X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FScript%2FServer.pm;h=1ec97a34ccbd337714b85859d66c64f0a290e019;hp=6d44bd4256b0e66cce5c1e8068f1b410bef95fad;hb=9c74923de2304b8c8f0a7a2faa0854ad9b4d3a92;hpb=b1bfeea6b5a93af08341739456d587bd5455caf9 diff --git a/lib/Catalyst/Script/Server.pm b/lib/Catalyst/Script/Server.pm index 6d44bd4..1ec97a3 100644 --- a/lib/Catalyst/Script/Server.pm +++ b/lib/Catalyst/Script/Server.pm @@ -1,18 +1,13 @@ package Catalyst::Script::Server; - -BEGIN { - $ENV{CATALYST_ENGINE} ||= 'HTTP'; - require Catalyst::Engine::HTTP; -} - use Moose; use MooseX::Types::Common::Numeric qw/PositiveInt/; use MooseX::Types::Moose qw/ArrayRef Str Bool Int RegexpRef/; +use Catalyst::Utils; use namespace::autoclean; -with 'Catalyst::ScriptRole'; +sub _plack_engine_name { 'Standalone' } -__PACKAGE__->meta->get_attribute('help')->cmd_aliases('?'); +with 'Catalyst::ScriptRole'; has debug => ( traits => [qw(Getopt)], @@ -45,7 +40,9 @@ has port => ( cmd_aliases => 'p', isa => PositiveInt, is => 'ro', - default => 3000, + default => sub { + Catalyst::Utils::env_value(shift->application_name, 'port') || 3000 + }, documentation => 'Specify a different listening port (to the default port 3000)', ); @@ -80,7 +77,9 @@ has restart => ( cmd_aliases => 'r', isa => Bool, is => 'ro', - default => 0, + default => sub { + Catalyst::Utils::env_value(shift->application_name, 'reload') || 0; + }, documentation => 'use Catalyst::Restarter to detect code changes and restart the application', ); @@ -179,12 +178,22 @@ sub run { } +sub _plack_loader_args { + my ($self) = shift; + return ( + port => $self->port, + host => $self->host, + keepalive => $self->keepalive ? 100 : 1, + ); +} + sub _application_args { my ($self) = shift; return ( $self->port, $self->host, { + argv => $self->ARGV, map { $_ => $self->$_ } qw/ fork keepalive @@ -225,7 +234,7 @@ Catalyst::Script::Server - Catalyst test server a restart when modified (defaults to '\.yml$|\.yaml$|\.conf|\.pm$') --rdir --restart_directory the directory to search for - modified files, can be set mulitple times + modified files, can be set multiple times (defaults to '[SCRIPT_DIR]/..') --sym --follow_symlinks follow symlinks in search directories (defaults to false. this is a no-op on Win32)