1 package Catalyst::EngineLoader;
3 use Catalyst::Exception;
5 use namespace::autoclean;
7 extends 'Plack::Loader';
9 has application_name => (
15 has compat_options => (
19 default => sub { +{} },
21 has_compat_option => 'exists',
22 compat_option => 'get',
26 sub needs_psgi_engine_compat_hack {
28 return $self->has_compat_option('requested_engine')
29 && $self->compat_option('requested_engine') eq 'PSGI';
32 has catalyst_engine_class => (
36 builder => '_guess_catalyst_engine_class',
39 sub _guess_catalyst_engine_class {
41 my $old_engine = Catalyst::Utils::env_value($self->application_name, 'ENGINE');
42 if (!defined $old_engine) {
43 return 'Catalyst::Engine';
45 elsif ($old_engine =~ /^(CGI|FCGI|HTTP|Apache.*)$/) {
46 return 'Catalyst::Engine';
49 return 'Catalyst::Engine::' . $old_engine;
54 my ($orig, $self) = (shift, shift);
55 my $engine = $self->$orig(@_);
56 if ($engine eq 'Standalone') {
57 if ( $ENV{MOD_PERL} ) {
58 my ( $software, $version ) =
59 $ENV{MOD_PERL} =~ /^(\S+)\/(\d+(?:[\.\_]\d+)+)/;
61 $version =~ s/(\.[^.]+)\./$1/g;
63 if ( $software eq 'mod_perl' ) {
64 if ( $version >= 1.99922 ) {
68 elsif ( $version >= 1.9901 ) {
69 Catalyst::Exception->throw( message => 'Plack does not have a mod_perl 1.99 handler' );
70 $engine = 'Apache2::MP19';
73 elsif ( $version >= 1.24 ) {
78 Catalyst::Exception->throw( message =>
79 qq/Unsupported mod_perl version: $ENV{MOD_PERL}/ );
85 my $old_engine = Catalyst::Utils::env_value($self->application_name, 'ENGINE');
86 if (!defined $old_engine) { # Not overridden
88 elsif ($old_engine =~ /^(CGI|FCGI|HTTP|Apache.*)$/) {
91 elsif ($old_engine eq "HTTP::Prefork") { # Too bad if you're customising, we don't handle options
92 # write yourself a script to collect and pass in the options
95 elsif ($old_engine eq "HTTP::POE") {
96 Catalyst::Exception->throw("HTTP::POE engine no longer works, recommend you use Twiggy instead");
98 elsif ($old_engine eq "Zeus") {
99 Catalyst::Exception->throw("Zeus engine no longer works");
102 warn("You asked for an unrecognised engine '$old_engine' which is no longer supported, this has been ignored.\n");
108 # Force constructor inlining
109 __PACKAGE__->meta->make_immutable( replace_constructor => 1 );
117 Catalyst::EngineLoader - The Catalyst Engine Loader
125 Wrapper on L<Plack::Loader> which resets the ::Engine if you are using some
130 Catalyst Contributors, see Catalyst.pm
134 This library is free software. You can redistribute it and/or modify it under
135 the same terms as Perl itself.
139 needs_psgi_engine_compat_hack