git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: Tatsuhiko Miyagawa <miyagawa@gmail.com>
Cc: git@vger.kernel.org, Peter Vereshagin <peter@vereshagin.org>,
	Petr Baudis <pasky@suse.cz>, Eric Wong <normalperson@yhbt.net>,
	Sam Vilain <sam.vilain@catalyst.net.nz>,
	Juan Jose Comellas <juanjo@comellas.org>,
	John Goerzen <jgoerzen@complete.org>
Subject: Re: gitweb, FastCGI and PSGI/Plack
Date: Mon, 10 May 2010 01:05:48 +0200	[thread overview]
Message-ID: <201005100105.49985.jnareb@gmail.com> (raw)
In-Reply-To: <g2s693254b91005091428ib188cbd1le5ffa90eace741a8@mail.gmail.com>

On Sun, 9 May 2010, Tatsuhiko Miyagawa wrote:

> I'm not subscribed to the git mailing list but:
> 
> http://www.spinics.net/lists/git/msg131014.html

You don't need to be subscribed to post to git mailing list.  I personally
read it with a news reader using GMane NNTP interface

  nntp://news.gmane.org/gmane.comp.version-control.git

but sending messages via email, to git@ver.kernel.org.  Usually people
reply both to original poster and to git mailing list, but just in case
you can mention that you are not subscribed, and to not forget to send
you a CC copy.


All CC re-added.

> 
> > Actually both CGI and CGI::Fast are in Perl core distribution since
> > perl 5.004 (Perl 5.4.0).  I assume that CGI::Fast simply degrades to CGI
> > if FCGI module is not present.
> 
> No, it just dies if FCGI is not installed

Ah, so that is why CGI distribution has FCGI as requirement!

  http://deps.cpantesters.org/?module=CGI;perl=latest

> (so CGI::Fast in core doesn't make any sense).

Yes, it doesn't.

Nevertheless gitweb would try to require CGI::Fast only when it is run
with '--fastcgi' / '--fcgi' / '-f' option.  It should probably check if
it can be require'd without errors, like it is done for FCGI::ProcManager
in
  [RFC/PATCHv2 2/2] gitweb: Add support for FastCGI, using CGI::Fast
  Message-Id: <201005080959.01800.jnareb@gmail.com>
  http://article.gmane.org/gmane.comp.version-control.git/146647

> 
> > JN> Yes, it can.  CGI::Compile is used for example by CGI::Emulate::PSGI,
> > JN> and you can run PSGI app on standalone Perl web server (pure Perl
> > JN> HTTP::Server::PSGI, or HTTP::Server::Simple::PSGI which in turn uses
> > JN> HTTP::Server::Simple, or Starman, or Twiggy, or Perlbal)
> 
> And FastCGI.
> 
> I don't understand why you implemented FastCGI interface *in addition
> to* PSGI/Plack interface.

I didn't implement support for PSGI/Plack, at least not in patch send in
"[PATCH 0/2] gitweb: Add support for running gitweb as FastCGI script"
series.

Adding support for FastCGI to CGI application is as simple as using
CGI::Fast object in place of CGI, and wrapping running main subroutine
in a loop that processes requests, like described in CGI::Fast manpage.
Well, for gitweb it required a few more small changes, anyway...

Moving to PSGI, or adding possibility to run gitweb as PSGI script (like
the series adds *ability* to run gitweb as FastCGI script) by modifying
gitweb would not be that easy, even with help of CGI::PSGI.


CGI::Compile was referring to an alternate approach, where instead of
modifying gitweb to be able to run it as FastCGI script (you can run it
as CGI script and as ModPerl::Registry script from mod_perl) there was
added gitweb.fcgi wrapper:

JN> The alternate solution would be to add gitweb.fcgi wrapper, like e.g.:
JN> in the following patch by Eric Wong
JN> 
JN>  "[PATCH 1/2] gitweb: add a simple wrapper for FCGI support"
JN>  http://thread.gmane.org/gmane.comp.version-control.git/35920/focus=35921
JN>
JN> which was part of the "[0/2 PATCH] FastCGI and nginx support for gitweb"
JN> series.  (Note that the patch does 'do $gitweb_cgi;' without checking for
JN> errors, see the bottom of `perldoc -f do` documentation on how it should
JN> be done).

One can of course use this approach wrapping gitweb to be run on PSGI,
using CGI::Emulate::PSGI (via Plack::App::WrapCGI), which in turn uses
CGI::Compile.  The gitweb.fcgi wrapper could use CGI::Emulate::FCGI...
if it existed.

NB I use the following gitweb.psgi wrapper to run gitweb from "plackup"
for tests (after running "make gitweb", of course, and with appropriate
gitweb_config.perl, unversioned, in gitweb/ alongside gitweb.perl, the
gitweb.psgi wrapper, and generated gitweb.cgi):

-- 8< --
#!/usr/bin/env plackup

# gitweb - simple web interface to track changes in git repositories
#          PSGI wrapper (see http://plackperl.org)

use strict;
use warnings;

use Plack::Builder;
use Plack::App::WrapCGI;
use CGI::Emulate::PSGI 0.07; # minimum version required to work

use File::Spec;
# __DIR__ is taken from Dir::Self __DIR__ fragment
sub __DIR__ () {
	File::Spec->rel2abs(join '', (File::Spec->splitpath(__FILE__))[0, 1]);
}

builder {
	enable 'Static',
		path => sub { m!\.(js|css|png)$! && s!^/gitweb/!! }, root => __DIR__."/";
	Plack::App::WrapCGI->new(script => __DIR__."/gitweb.cgi")->to_app;
}

__END__
-- >8 --

> 
> `plackup -s FCGI` makes your PSGI app a fastcgi handler using FCGI.pm,
> or `plackup -s Net::FastCGI` does the same but using Net::FastCGI,
> pure perl alternative.

It is a pity that Plack::App::WrapFCGI / FCGI::Emulate::PSGI does not
exist, so that gitweb.psgi wrapper would not require indirectly 
CGI::Compile.

> 
> Come over to #plack (irc://irc.perl.org/#plack) for more discussion.

Email not good?

-- 
Jakub Narebski
ShadeHawk on #git, jnareb on #plack
Poland

       reply	other threads:[~2010-05-09 23:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <g2s693254b91005091428ib188cbd1le5ffa90eace741a8@mail.gmail.com>
2010-05-09 23:05 ` Jakub Narebski [this message]
2010-05-10  0:59   ` gitweb, FastCGI and PSGI/Plack Tatsuhiko Miyagawa
2010-05-10 16:26     ` Jakub Narebski
2010-05-10 17:14       ` Tatsuhiko Miyagawa
2010-05-10  1:05   ` Tatsuhiko Miyagawa
2010-05-10 10:32     ` Jakub Narebski
2010-05-10 17:03       ` Tatsuhiko Miyagawa
2010-05-10 18:40         ` Jakub Narebski
2010-05-10 18:43           ` Tatsuhiko Miyagawa
2010-05-10 21:10             ` Jakub Narebski
2010-05-11  0:07               ` Tatsuhiko Miyagawa
2010-05-11  9:29                 ` Jakub Narebski
2010-05-11  9:44                   ` Peter Vereshagin
2010-05-11 18:56                     ` Tatsuhiko Miyagawa

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=201005100105.49985.jnareb@gmail.com \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jgoerzen@complete.org \
    --cc=juanjo@comellas.org \
    --cc=miyagawa@gmail.com \
    --cc=normalperson@yhbt.net \
    --cc=pasky@suse.cz \
    --cc=peter@vereshagin.org \
    --cc=sam.vilain@catalyst.net.nz \
    /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).