@matheusbsbs / matheus-bagliano / commits / 45aa9895c5
Fork 0

gitweb: Run in FastCGI mode if gitweb script has .fcgi extension

If the name of the script ($SCRIPT_NAME or $SCRIPT_FILENAME CGI environment variable, or __FILE__ literal) ends with '.fcgi' extension, run gitweb in FastCGI mode, as if it was run with '--fastcgi' / '--fcgi' option. This is intended for easy deploying gitweb using FastCGI interface. Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jakub Narebski committed Jun 5, 2010 at 23:11 UTC 45aa9895c5bef3914b6f3707b983f7a53900ebb7
1 file changed +13 -8
gitweb/gitweb.perl
+13 -8
@@ -1025,19 +1025,24 @@ our $is_last_request = sub { 1 };
1025 our ($pre_dispatch_hook, $post_dispatch_hook, $pre_listen_hook);
1026 our $CGI = 'CGI';
1027 our $cgi;
1028 +sub configure_as_fcgi {
1029 + require CGI::Fast;
1030 + our $CGI = 'CGI::Fast';
1031 +
1032 + my $request_number = 0;
1033 + # let each child service 100 requests
1034 + our $is_last_request = sub { ++$request_number > 100 };
1035 +}
1036 sub evaluate_argv {
1037 + my $script_name = $ENV{'SCRIPT_NAME'} || $ENV{'SCRIPT_FILENAME'} || __FILE__;
1038 + configure_as_fcgi()
1039 + if $script_name =~ /\.fcgi$/;
1040 +
1041 return unless (@ARGV);
1042
1043 require Getopt::Long;
1044 Getopt::Long::GetOptions(
1033 - 'fastcgi|fcgi|f' => sub {
1034 - require CGI::Fast;
1035 - our $CGI = 'CGI::Fast';
1036 -
1037 - my $request_number = 0;
1038 - # let each child service 100 requests
1039 - our $is_last_request = sub { ++$request_number > 100 };
1040 - },
1045 + 'fastcgi|fcgi|f' => \&configure_as_fcgi,
1046 'nproc|n=i' => sub {
1047 my ($arg, $val) = @_;
1048 return unless eval { require FCGI::ProcManager; 1; };