X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FScript%2FServer.pm;h=983a995e42c0b721c286e3576caa713814a56801;hb=807303a1658f895c41417beba24d24ff9b71c194;hp=270490ef4bfedd41ab1c68cacda586bc5ac65f70;hpb=8c848c3350612cba6e19d8fc4cdf4717760f62ae;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Script/Server.pm b/lib/Catalyst/Script/Server.pm index 270490e..983a995 100644 --- a/lib/Catalyst/Script/Server.pm +++ b/lib/Catalyst/Script/Server.pm @@ -1,7 +1,7 @@ package Catalyst::Script::Server; use Moose; use Catalyst::Utils; -use Try::Tiny; +use Class::Load qw(try_load_class load_class); use namespace::autoclean; with 'Catalyst::ScriptRole'; @@ -37,6 +37,7 @@ has port => ( cmd_aliases => 'p', isa => 'Int', is => 'ro', + lazy => 1, default => sub { Catalyst::Utils::env_value(shift->application_name, 'port') || 3000 }, @@ -49,11 +50,9 @@ subtype 'Catalyst::Script::Server::Types::Pidfile', as 'MooseX::Daemonize::Pid::File'; coerce 'Catalyst::Script::Server::Types::Pidfile', from 'Str', via { - try { Class::MOP::load_class("MooseX::Daemonize::Pid::File") } - catch { - warn("Could not load MooseX::Daemonize::Pid::File, needed for --pid option\n"); - exit 1; - }; + my ($success, $error) = try_load_class("MooseX::Daemonize::Pid::File"); + warn("Could not load MooseX::Daemonize::Pid::File, needed for --pid option: $error\n"), + exit 1 if not $success; MooseX::Daemonize::Pid::File->new( file => $_ ); }; MooseX::Getopt::OptionTypeMap->add_option_type_to_map( @@ -76,11 +75,11 @@ sub BUILD { if ($self->background) { # FIXME - This is evil. Should we just add MX::Daemonize to the deps? - try { Class::MOP::load_class('MooseX::Daemonize::Core'); Class::MOP::load_class('POSIX') } - catch { - warn("MooseX::Daemonize is needed for the --background option\n"); - exit 1; - }; + my ($success, $error) = try_load_class("MooseX::Daemonize::Core"); + warn("MooseX::Daemonize is needed for the --background option: $error\n"), + exit 1 if not $success; + ($success, $error) = try_load_class("POSIX"); + warn("$error\n"), exit 1 if not $success; MooseX::Daemonize::Core->meta->apply($self); POSIX::close($_) foreach (0..2); } @@ -109,6 +108,7 @@ has restart => ( cmd_aliases => 'r', isa => 'Bool', is => 'ro', + lazy => 1, default => sub { Catalyst::Utils::env_value(shift->application_name, 'reload') || 0; }, @@ -229,7 +229,7 @@ sub run { return 1 unless $self->is_daemon; - Class::MOP::load_class($self->application_name); + load_class($self->application_name); $self->daemon_detach; }