From: Jakub Narebski <jnareb@gmail.com>
To: "Juan Jose Comellas" <juanjo@comellas.org>, Sam Vilain <sam@vilain.net>
Cc: git@vger.kernel.org
Subject: Re: FastCGI support in gitweb
Date: Sat, 01 Mar 2008 13:50:23 -0800 (PST) [thread overview]
Message-ID: <m38x12jeqt.fsf@localhost.localdomain> (raw)
In-Reply-To: <1c3be50f0803011334u2629011cg85cb8728a244ea4e@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1010 bytes --]
"Juan Jose Comellas" <juanjo@comellas.org> writes:
> I've seen that the current version of Gitweb (1.5.4.2) does not
> support FastCGI, and looking in Google I found that about a year ago a
> patch was sent to the list adding this functionality to it. I couldn't
> find any additional emails indicating why they weren't accepted. Is
> there any plan to add FastCGI support to Gitweb?
First, as far as I understand it, the patch made gitweb had to be used
with FastCGI server. It has no comments in code, and if I remember
correctly the commit message was also fairly nonexistent. It mixes
FastCGI changes with site-wide changes. It wrapped the whole file in
"until last request" loop instead of wrapping dispatch only.
Also I am not sure if gitweb doesn't rely on variables being correctly
set which they are not in FastCGI mode.
But most important part: it was never resend (IIRC it was send when
gitweb development was in separate repository)
I have attached the FastCGI patch and CC-ed the author.
[-- Attachment #2: gitweb-FastCGI.patch --]
[-- Type: text/plain, Size: 4373 bytes --]
From: root <root@vgasm.watts.utsl.gen.nz>
Date: Wed, 22 Mar 2006 00:53:07 +0000 (+1200)
Subject: add support for FastCGI
X-Git-Url: http://utsl.gen.nz/gitweb/?p=gitweb;a=commitdiff;h=56d7d436644ab296155a697552ea1345f2701620
add support for FastCGI
---
--- a/gitweb.cgi
+++ b/gitweb.cgi
@@ -5,10 +5,22 @@
# (C) 2005, Kay Sievers <kay.sievers@vrfy.org>
# (C) 2005, Christian Gierke <ch@gierke.de>
#
+# FastCGI adaptations:
+# (c) 2006, Sam Vilain <sam.vilain@catalyst.net.nz>
+#
# This program is licensed under the GPLv2
+#
+
use strict;
use warnings;
+
+my $last_request = sub { 1 };
+my $pre_dispatch_hook = sub { };
+my $post_dispatch_hook = sub { };
+my $CGI = "CGI";
+my $pre_listen_hook = sub { };
+
use CGI qw(:standard :escapeHTML -nosticky);
use CGI::Util qw(unescape);
use CGI::Carp qw(fatalsToBrowser);
@@ -16,7 +28,34 @@ use Encode;
use Fcntl ':mode';
binmode STDOUT, ':utf8';
-my $cgi = new CGI;
+ if (@ARGV) {
+ require Getopt::Long;
+ Getopt::Long::GetOptions
+ ( "fastcgi|f" => sub {
+ require CGI::Fast;
+ $CGI = "CGI::Fast";
+ my $c;
+ # let each child service 100 requests
+ $last_request = sub { ++$c > 100 }
+ },
+ "nproc|n=i" => sub {
+ my ($arg, $val) = @_;
+ require FCGI::ProcManager;
+ my $pm = FCGI::ProcManager->new({
+ n_processes => $val,
+ });
+ $pre_listen_hook = sub { $pm->pm_manage };
+ $pre_dispatch_hook = sub { $pm->pm_pre_dispatch };
+ $post_dispatch_hook = sub { $pm->pm_post_dispatch };
+ },
+ );
+ }
+
+$pre_listen_hook->();
+do {
+my $cgi = $CGI->new or last;
+$pre_dispatch_hook->();
+
my $version = "264";
my $my_url = $cgi->url();
my $my_uri = $cgi->url(-absolute => 1);
@@ -24,7 +63,7 @@ my $rss_link = "";
# absolute fs-path which will be prepended to the project path
#my $projectroot = "/pub/scm";
-my $projectroot = "/home/kay/public_html/pub/scm";
+my $projectroot = "/var/lib/git";
# location of the git-core binaries
my $gitbin = "/usr/bin";
@@ -40,7 +79,7 @@ my $home_text = "indextext.html";
# source of projects list
#my $projects_list = $projectroot;
-my $projects_list = "index/index.aux";
+my $projects_list = "/var/lib/git";
# input validation and dispatch
my $action = $cgi->param('a');
@@ -51,10 +90,10 @@ if (defined $action) {
}
if ($action eq "git-logo.png") {
git_logo();
- exit;
+ goto out;
} elsif ($action eq "opml") {
git_opml();
- exit;
+ goto out;
}
}
@@ -85,7 +124,7 @@ if (defined $project) {
$ENV{'GIT_DIR'} = "$projectroot/$project";
} else {
git_project_list();
- exit;
+ goto out;
}
my $file_name = $cgi->param('f');
@@ -154,61 +193,62 @@ sub validate_input {
if (!defined $action || $action eq "summary") {
git_summary();
- exit;
+ goto out;
} elsif ($action eq "heads") {
git_heads();
- exit;
+ goto out;
} elsif ($action eq "tags") {
git_tags();
- exit;
+ goto out;
} elsif ($action eq "blob") {
git_blob();
- exit;
+ goto out;
} elsif ($action eq "blob_plain") {
git_blob_plain();
- exit;
+ goto out;
} elsif ($action eq "tree") {
git_tree();
- exit;
+ goto out;
} elsif ($action eq "rss") {
git_rss();
- exit;
+ goto out;
} elsif ($action eq "commit") {
git_commit();
- exit;
+ goto out;
} elsif ($action eq "log") {
git_log();
- exit;
+ goto out;
} elsif ($action eq "blobdiff") {
git_blobdiff();
- exit;
+ goto out;
} elsif ($action eq "blobdiff_plain") {
git_blobdiff_plain();
- exit;
+ goto out;
} elsif ($action eq "commitdiff") {
git_commitdiff();
- exit;
+ goto out;
} elsif ($action eq "commitdiff_plain") {
git_commitdiff_plain();
- exit;
+ goto out;
} elsif ($action eq "history") {
git_history();
- exit;
+ goto out;
} elsif ($action eq "search") {
git_search();
- exit;
+ goto out;
} elsif ($action eq "shortlog") {
git_shortlog();
- exit;
+ goto out;
} elsif ($action eq "tag") {
git_tag();
- exit;
+ goto out;
} else {
undef $action;
die_error(undef, "Unknown action.");
- exit;
}
+$post_dispatch_hook->();
+
# quote unsafe chars, but keep the slash, even when it's not
# correct, but quoted slashes look too horrible in bookmarks
sub esc_param {
@@ -2405,3 +2445,7 @@ sub git_shortlog {
print "</table\n>";
git_footer_html();
}
+
+out:
+ exit;
+} until ( $last_request->() );
[-- Attachment #3: Type: text/plain, Size: 45 bytes --]
--
Jakub Narebski
Poland
ShadeHawk on #git
next prev parent reply other threads:[~2008-03-01 21:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-01 21:34 FastCGI support in gitweb Juan Jose Comellas
2008-03-01 21:50 ` Jakub Narebski [this message]
2008-03-03 12:28 ` Sam Vilain
2008-03-04 0:19 ` Jakub Narebski
2008-03-04 3:59 ` John Goerzen
2008-03-04 10:11 ` Jakub Narebski
2008-03-04 14:48 ` John Goerzen
2008-03-04 17:22 ` Jakub Narebski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m38x12jeqt.fsf@localhost.localdomain \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
--cc=juanjo@comellas.org \
--cc=sam@vilain.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).