root/fastcgi/trunk/mt-dispatch.fcgi

Revision 176, 1.0 kB (checked in by ogawa, 3 years ago)

Append noexit versions.
Use request_uri for mt-dispatch.fcgi.

Line 
1#!/usr/bin/perl -w
2use strict;
3use lib 'lib';
4use MT::Bootstrap;
5use CGI::Fast;
6
7my $handlers = {
8    'mt.fcgi' => 'MT::App::CMS',
9    'mt-comments.fcgi' => 'MT::App::Comments',
10    'mt-tb.fcgi' => 'MT::App::Trackback',
11    'mt-search.fcgi' => 'MT::App::Search',
12## uncomment if necessary, but this adds a lot of
13## overhead since it loads up LibXML.
14##    'mt-atom.fcgi' => 'MT::AtomServer',
15};
16eval "use $_" foreach (values %$handlers);
17
18eval {
19    while (my $q = new CGI::Fast) {
20        my($cgi) = $q->request_uri =~ m!.*/(.*\.fcgi)!;
21        my $pkg = $handlers->{$cgi};
22        die "Invalid handler for $cgi" unless $pkg;
23        my $app = $pkg->new(CGIObject => $q) or die $pkg->errstr;
24        local $SIG{__WARN__} = sub { $app->trace($_[0]) };
25        MT->set_instance($app);
26        $app->init_request(CGIObject => $q) unless $app->{init_request};
27        $app->run;
28        my $mode = $app->mode || '';
29        if ("$pkg->$mode" eq 'MT::App::CMS->plugin_control') {
30            exit; # allows server to recycle after changing plugin switches
31        }
32    }
33};
34if ($@) {
35    print "Content-Type: text/html\n\n";
36    print "Got an error: $@";
37}
Note: See TracBrowser for help on using the browser.