1 package Catalyst::EngineLoader;
3 use Catalyst::Exception;
5 use namespace::autoclean;
7 extends 'Plack::Loader';
9 has application_name => (
15 has catalyst_engine_class => (
19 builder => '_guess_catalyst_engine_class',
22 sub _guess_catalyst_engine_class {
24 my $old_engine = Catalyst::Utils::env_value($self->application_name, 'ENGINE');
25 if (!defined $old_engine) {
26 return 'Catalyst::Engine';
28 elsif ($old_engine =~ /^(CGI|FCGI|HTTP|Apache.*)$/) {
29 return 'Catalyst::Engine';
32 return 'Catalyst::Engine::' . $old_engine;
37 my ($orig, $self) = (shift, shift);
38 my $engine = $self->$orig(@_);
39 if ($engine eq 'Standalone') {
40 if ( $ENV{MOD_PERL} ) {
41 my ( $software, $version ) =
42 $ENV{MOD_PERL} =~ /^(\S+)\/(\d+(?:[\.\_]\d+)+)/;
44 $version =~ s/(\.[^.]+)\./$1/g;
46 if ( $software eq 'mod_perl' ) {
47 if ( $version >= 1.99922 ) {
51 elsif ( $version >= 1.9901 ) {
52 Catalyst::Exception->throw( message => 'Plack does not have a mod_perl 1.99 handler' );
53 $engine = 'Apache2::MP19';
56 elsif ( $version >= 1.24 ) {
61 Catalyst::Exception->throw( message =>
62 qq/Unsupported mod_perl version: $ENV{MOD_PERL}/ );
68 my $old_engine = Catalyst::Utils::env_value($self->application_name, 'ENGINE');
69 if (!defined $old_engine) { # Not overridden
71 elsif ($old_engine =~ /^(CGI|FCGI|HTTP|Apache.*)$/) {
74 elsif ($old_engine eq "HTTP::Prefork") { # Too bad if you're customising, we don't handle options
75 # write yourself a script to collect and pass in the options
78 elsif ($old_engine eq "HTTP::POE") {
79 Catalyst::Exception->throw("HTTP::POE engine no longer works, recommend you use Twiggy instead");
81 elsif ($old_engine eq "Zeus") {
82 Catalyst::Exception->throw("Zeus engine no longer works");
85 warn("You asked for an unrecognised engine '$old_engine' which is no longer supported, this has been ignored.\n");
91 # Force constructor inlining
92 __PACKAGE__->meta->make_immutable( replace_constructor => 1 );
100 Catalyst::EngineLoader - The Catalyst Engine Loader
108 Wrapper on L<Plack::Loader> which resets the ::Engine if you are using some
113 Catalyst Contributors, see Catalyst.pm
117 This library is free software. You can redistribute it and/or modify it under
118 the same terms as Perl itself.