X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine%2FLoader.pm;h=5ac028fbd3dfd5e614fea8770c60e8ba59167d90;hb=1e5dad0099d51c919670c0e765615937b0fd4dae;hp=5de0acca8027705aa55f9bafac2e377243386a2f;hpb=df1fa879e566937a591446d454bb8d3a17a70a2c;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine/Loader.pm b/lib/Catalyst/Engine/Loader.pm index 5de0acc..5ac028f 100644 --- a/lib/Catalyst/Engine/Loader.pm +++ b/lib/Catalyst/Engine/Loader.pm @@ -1,19 +1,48 @@ package Catalyst::Engine::Loader; use Moose; use Catalyst::Exception; +use Catalyst::Utils; use namespace::autoclean; extends 'Plack::Loader'; +has application_name => ( + isa => 'Str', + is => 'ro', + required => 1, +); + +has catalyst_engine_class => ( + isa => 'Str', + is => 'rw', + lazy => 1, + builder => '_guess_catalyst_engine_class', +); + +sub _guess_catalyst_engine_class { + my $self = shift; + my $old_engine = Catalyst::Utils::env_value($self->application_name, 'ENGINE'); + if (!defined $old_engine) { + return 'Catalyst::Engine'; + } + elsif ($old_engine =~ /^(CGI|FCGI|HTTP|Apache.*)$/) { + return 'Catalyst::Engine'; + } + elsif (my ($type) = $old_engine =~ /^(Stomp|Test::MessageDriven|Wx)$/) { + return 'Catalyst::Engine::' . $type; + } +} + around guess => sub { my ($orig, $self) = (shift, shift); my $engine = $self->$orig(@_); if ($engine eq 'Standalone') { if ( $ENV{MOD_PERL} ) { my ( $software, $version ) = - $ENV{MOD_PERL} =~ /^(\S+)\/(\d+(?:[\.\_]\d+)+)/; - + $ENV{MOD_PERL} =~ /^(\S+)\/(\d+(?:[\.\_]\d+)+)/; $version =~ s/_//g; + $version =~ s/(\.[^.]+)\./$1/g; + if ( $software eq 'mod_perl' ) { if ( $version >= 1.99922 ) { $engine = 'Apache2'; @@ -35,10 +64,32 @@ around guess => sub { } } } + + my $old_engine = Catalyst::Utils::env_value($self->application_name, 'ENGINE'); + if (!defined $old_engine) { # Not overridden + } + elsif ($old_engine =~ /^(CGI|FCGI|HTTP|Apache.*)$/) { + # Trust autodetect + } + elsif ($old_engine eq "HTTP::Prefork") { # Too bad if you're customising, we don't handle options + # write yourself a script to collect and pass in the options + $engine = "Starman"; + } + elsif ($old_engine eq "HTTP::POE") { + Catalyst::Exception->throw("HTTP::POE engine no longer works, recommend you use Twiggy instead"); + } + elsif ($old_engine eq "Zeus") { + Catalyst::Exception->throw("Zeus engine no longer works"); + } + else { + warn("You asked for an unrecognised engine '$old_engine' which is no longer supported, this has been ignored.\n"); + } + return $engine; }; -__PACKAGE__->meta->make_immutable( inline_constructor => 0 ); +# Force constructor inlining +__PACKAGE__->meta->make_immutable( replace_constructor => 1 ); 1;