X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FScript%2FServer.pm;h=0f55d86c23056f1986f7c459b5417816541e2489;hb=50a65bb3660cd8253a592f005cafa2b3768f90fb;hp=7798c558482893171ba576b8244af8df022eb410;hpb=36a53c3a41947085d7acaa50ccf67e85802e6b9d;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Script/Server.pm b/lib/Catalyst/Script/Server.pm index 7798c55..0f55d86 100644 --- a/lib/Catalyst/Script/Server.pm +++ b/lib/Catalyst/Script/Server.pm @@ -9,8 +9,6 @@ sub _plack_engine_name { 'Standalone' } with 'Catalyst::ScriptRole'; -__PACKAGE__->meta->get_attribute('help')->cmd_aliases('?'); - has debug => ( traits => [qw(Getopt)], cmd_aliases => 'd', @@ -142,9 +140,22 @@ sub _restarter_args { ($self->_has_restart_delay ? (sleep_interval => $self->restart_delay) : ()), ($self->_has_restart_directory ? (directories => $self->restart_directory) : ()), ($self->_has_restart_regex ? (filter => $self->restart_regex) : ()), + ), + ( + map { $_ => $self->$_ } qw(application_name host port debug pidfile fork background keepalive) ); } +has restarter_class => ( + is => 'ro', + isa => Str, + lazy => 1, + default => sub { + my $self = shift; + Catalyst::Utils::env_value($self->application_name, 'RESTARTER') || 'Catalyst::Restarter'; + } +); + sub run { my $self = shift; @@ -163,9 +174,9 @@ sub run { # fail. $| = 1 if $ENV{HARNESS_ACTIVE}; - require Catalyst::Restarter; + Catalyst::Utils::ensure_class_loaded($self->restarter_class); - my $subclass = Catalyst::Restarter->pick_subclass; + my $subclass = $self->restarter_class->pick_subclass; my $restarter = $subclass->new( $self->_restarter_args() @@ -186,6 +197,15 @@ sub _plack_loader_args { port => $self->port, host => $self->host, keepalive => $self->keepalive ? 100 : 1, + server_ready => sub { + my ($args) = @_; + + my $name = $args->{server_software} || ref($args); # $args is $server + my $host = $args->{host} || 0; + my $proto = $args->{proto} || 'http'; + + print STDERR "$name: Accepting connections at $proto://$host:$args->{port}/\n"; + }, ); } @@ -195,6 +215,7 @@ sub _application_args { $self->port, $self->host, { + argv => $self->ARGV, map { $_ => $self->$_ } qw/ fork keepalive @@ -235,7 +256,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)