git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: gitweb, FastCGI and PSGI/Plack

From
Jakub Narebski <jnareb@gmail.com>
Date
May 10, 2010, 21:10 UTC
Message-ID
<201005102310.47879.jnareb@gmail.com>
In-Reply-To
<AANLkTilXqAUs5-go-JHgTrQuslTyA1sZ3re5yuLtnxkz@mail.gmail.com>
On Mon, 10 May 2010, Tatsuhiko Miyagawa wrote:
Show 20 quoted lines
> On Mon, May 10, 2010 at 11:40 AM, Jakub Narebski <jnareb@gmail.com> wrote:
>> On Mon, 10 May 2010, Tatsuhiko Miyagawa wrote:
>>> 
>>> Yes, that makes sense - if implementing FastCGI is just switching CGI
>>> to CGI::Fast and a while loop, implementing PSGI interface just for
>>> that is far more complicated. I just argued about it because I saw on
>>> a separate thread that PSGI implementation is also on its way.
>>
>> What!?  No, currently there are no plans to add PSGI support to gitweb,
>> nor moving gitweb from CGI (and mod_perl's ModPerl::Registry, and
>> FastCGI now) to PSGI.
>>
>> This separate thread is about adding support for 'plackup' to
>> git-instaweb (and perhaps also adding gitweb.psgi wrapper).
> 
> Yes, that's what I meant.
> 
> If you get plackup support by converting your CGI application into a
> PSGI app, then adding support to FastCGI is just one command line
> option away.

Well, the support for 'plackup' in git-instaweb is / would be done not by converting gitweb from CGI to PSGI app, but by using gitweb.psgi wrapper. This wrapper uses Plack::App::WrapCGI (which in turn uses CGI::Emulate::PSGI, which in turn use CGI::Compile) to wrap gitweb.cgi, and Plack::Middleware::Static to serve static files (gitweb.css, gitweb.js, git-favicon.png, git-logo.png).

To be more exact in current, as yet unpublished version, git-instaweb generates gitweb.psgi on-the-fly. I am considering adding gitweb.psgi wrapper to git repository (to git sources); when building git-instaweb it would get embedded in $(gitexecdir)/git-instaweb, just like gitweb.cgi, gitweb.css (or gitweb.min.css) and gitweb.js (or gitweb.min.js) are. Running git-instaweb for first time would create _configured_ gitweb.cgi in $GIT_DIR/gitweb. For "plackup" git-instaweb would put configured gitweb.psgi (or app.psgi) there; for other web servers git-instaweb puts httpd.conf there.

It is true that with gitweb.psgi wrapper running gitweb as FastCGI script is just one command line option away. But it does require Plack to be installed... well, on the other hand the modified gitweb needs FCGI module to be ran as FastCGI script, which is not a CORE Perl module either.

I also wonder how running via wrapper script affect performance, as compared to modified gitweb running as FastCGI script, using CGI::Fast and FCGI.

P.S. A bit of history: original patch by Sam Vilain adding FastCGI support by using CGI::Fast is from 2006. Eric Wong patch adding gitweb.fcgi wrapper (with 'no warnings; do $file' instead of modern CGI::Compile->compile($file)) is from 2007.

I have originally replaced 'exit' in die_error() subroutine by non-local jump to the end of request processing in ultimately a bit failed attempt to use die_error() in CGI::Carp::set_message(), because when using 'exit' the error didn't get logged (unfortunately you can set error message, but you can set HTTP headers for error message this way).

I have then noticed that this change would also allow to add FastCGI support to gitweb in a very simple way. Therefore I have ported Sam Vilain patch to modern gitweb codebase. Well, it did require some restructuring of gitweb code (some refactoring), so it wasn't that simple... nevertheless I think that this refactoring is mainly a good change anyway.

P.P.S. One of constraints to gitweb development is that it should run with minimal set of non-core modules. Some people even complain that gitweb (or was it about git in general?) requires at least Perl 5.8.6 or about (because of Encode module and Unicode support).

If one wants Modern Perl git web interface, there is always Gitalist...
-- 
Jakub Narebski, Poland
ShadeHawk on #git at FreeNode
jnareb on #plack at irc.perl.org
Previous: Tatsuhiko MiyagawaNext: Tatsuhiko Miyagawa
Message 10 of 14 in “Re: gitweb, FastCGI and PSGI/Plack”
  1. Jakub NarebskiMay 9, 2010
  2. Tatsuhiko MiyagawaMay 10, 2010
  3. Jakub NarebskiMay 10, 2010
  4. Tatsuhiko MiyagawaMay 10, 2010
  5. Tatsuhiko MiyagawaMay 10, 2010
  6. Jakub NarebskiMay 10, 2010
  7. Tatsuhiko MiyagawaMay 10, 2010
  8. Jakub NarebskiMay 10, 2010
  9. Tatsuhiko MiyagawaMay 10, 2010
  10. Jakub NarebskiMay 10, 2010
  11. Tatsuhiko MiyagawaMay 11, 2010
  12. Jakub NarebskiMay 11, 2010
  13. Peter VereshaginMay 11, 2010
  14. Tatsuhiko MiyagawaMay 11, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.