Skip to content

Commit 45aa989

Browse files
jnarebgitster
authored andcommitted
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>
1 parent a0446e7 commit 45aa989

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

gitweb/gitweb.perl

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,19 +1025,24 @@ sub run_request {
10251025
our ($pre_dispatch_hook, $post_dispatch_hook, $pre_listen_hook);
10261026
our $CGI = 'CGI';
10271027
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+
}
10281036
sub evaluate_argv {
1037+
my $script_name = $ENV{'SCRIPT_NAME'} || $ENV{'SCRIPT_FILENAME'} || __FILE__;
1038+
configure_as_fcgi()
1039+
if $script_name =~ /\.fcgi$/;
1040+
10291041
return unless (@ARGV);
10301042

10311043
require Getopt::Long;
10321044
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,
10411046
'nproc|n=i' => sub {
10421047
my ($arg, $val) = @_;
10431048
return unless eval { require FCGI::ProcManager; 1; };

0 commit comments

Comments
 (0)