1 package Catalyst::EngineLoader;
3 use Catalyst::Exception;
5 use namespace::autoclean;
7 extends 'Plack::Loader';
9 has application_name => (
15 has requested_engine => (
18 predicate => 'has_requested_engine',
21 sub needs_psgi_engine_compat_hack {
23 return $self->has_requested_engine
24 && $self->requested_engine eq 'PSGI';
27 has catalyst_engine_class => (
31 builder => '_guess_catalyst_engine_class',
34 sub _guess_catalyst_engine_class {
36 my $old_engine = $self->has_requested_engine
37 ? $self->requested_engine
38 : Catalyst::Utils::env_value($self->application_name, 'ENGINE');
39 if (!defined $old_engine) {
40 return 'Catalyst::Engine';
42 elsif ($old_engine eq 'PSGI') {
43 ## If we are running under plackup let the Catalyst::Engine::PSGI
44 ## continue to run, but warn.
46 You are running Catalyst::Engine::PSGI, which is considered a legacy engine for
47 this version of Catalyst. We will continue running and use your existing psgi
48 file, but it is recommended to perform the trivial upgrade process, which will
49 leave you with less code and a forward path.
51 Please review Catalyst::Upgrading
53 return 'Catalyst::Engine::' . $old_engine;
55 elsif ($old_engine =~ /^(CGI|FastCGI|HTTP|Apache.*)$/) {
56 return 'Catalyst::Engine';
59 return 'Catalyst::Engine::' . $old_engine;
64 my ($orig, $self) = (shift, shift);
65 my $engine = $self->$orig(@_);
66 if ($engine eq 'Standalone') {
67 if ( $ENV{MOD_PERL} ) {
68 my ( $software, $version ) =
69 $ENV{MOD_PERL} =~ /^(\S+)\/(\d+(?:[\.\_]\d+)+)/;
71 $version =~ s/(\.[^.]+)\./$1/g;
73 if ( $software eq 'mod_perl' ) {
74 if ( $version >= 1.99922 ) {
78 elsif ( $version >= 1.9901 ) {
79 Catalyst::Exception->throw( message => 'Plack does not have a mod_perl 1.99 handler' );
80 $engine = 'Apache2::MP19';
83 elsif ( $version >= 1.24 ) {
88 Catalyst::Exception->throw( message =>
89 qq/Unsupported mod_perl version: $ENV{MOD_PERL}/ );
95 my $old_engine = Catalyst::Utils::env_value($self->application_name, 'ENGINE');
96 if (!defined $old_engine) { # Not overridden
98 elsif ($old_engine =~ /^(PSGI|CGI|Apache.*)$/) {
101 elsif ($old_engine eq 'HTTP') {
102 $engine = 'Standalone';
104 elsif ($old_engine eq 'FastCGI') {
107 elsif ($old_engine eq "HTTP::Prefork") { # Too bad if you're customising, we don't handle options
108 # write yourself a script to collect and pass in the options
111 elsif ($old_engine eq "HTTP::POE") {
112 Catalyst::Exception->throw("HTTP::POE engine no longer works, recommend you use Twiggy instead");
114 elsif ($old_engine eq "Zeus") {
115 Catalyst::Exception->throw("Zeus engine no longer works");
118 warn("You asked for an unrecognised engine '$old_engine' which is no longer supported, this has been ignored.\n");
124 # Force constructor inlining
125 __PACKAGE__->meta->make_immutable( replace_constructor => 1 );
133 Catalyst::EngineLoader - The Catalyst Engine Loader
141 Wrapper on L<Plack::Loader> which resets the ::Engine if you are using some
146 Catalyst Contributors, see Catalyst.pm
150 This library is free software. You can redistribute it and/or modify it under
151 the same terms as Perl itself.
155 needs_psgi_engine_compat_hack