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

Re: [PATCH 0/2] gitweb: Add support for running gitweb as FastCGI script

From
Jakub Narebski <jnareb@gmail.com>
Date
May 9, 2010, 18:18 UTC
Message-ID
<201005092018.54580.jnareb@gmail.com>
In-Reply-To
<20100509164723.GA4638@screwed.box>
On Sun, 9 May 2010, Peter Vereshagin wrote:
Show 16 quoted lines
> I'm face to face with Jakub who sold the world?
> 2010/05/09 14:39:23 +0200 Jakub Narebski <jnareb@gmail.com> => To Eric Wong :
> 
> 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).  CGI::Compile
> JN> just compiles given CGI script into a subroutine, which can be called
> JN> many times in a persistent web environment like FastCGI.
> 
> Thanks a lot about that!
>
> I took a quick look at the patches and see this:
> - FastCGI people are not always happy with CGI.pm and thus with CGI::Fast that
>   derives from it. They prefer CGI::Simple, e. g. for the Catalyst on fastcgi
>   and other CGI.pm replacements.

CGI::Simple is not in core. For Catalyst folks it is not a problem, because Catalyst (one of Perl MVC web frameworks) is not in core either.

>   Despite the CGI::Fast is somehow the part of the perl core distribution
>   the FCGI.pm and CGI.pm which are the required dependencies are not.

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.

FCGI is the single non-core dependency of CGI, see 
  http://deps.cpantesters.org/?module=CGI;perl=latest
so when I upgraded CGI (locally, using cpan client and local::lib), I also
installed FCGI.
Show 5 quoted lines
>   Needless to say that the CGI.pm is not at all (because 
>   it tries too much to be) a 'killer app'. I myself is about to stop using
>   CGI::Fast in FCGI::Spawn in favor of regular FCGI.pm and the CGI.pm variant
>   chosen by the user. Needless to say that this can make the CGI.pm patching for
>   FCGI::Spawn unecessary.
That's nice.

What are required changes to gitweb to use FCGI::Spawn to run gitweb as a FastCGI script? Alternatively, how the wrapper script for gitweb (gitweb.fcgi) to be run as FastCGI should look like to use FCGI::Spawn?

> - FCGI::ProcManager is a piece of cake in any way, but there are 'more than one
>   way to do it' (c) and it should be mentioned on a docs as a dependency since
>   there are modules on CPAN too for the same purpose but promiseful of features
>   like OO/etc.

As PATCH 2/2 was straighforward port of Sam Vilain patch, I don't even know what exactly the part containing FCGI::ProcManager does.

Note however that FCGI::ProcManager is require'd on demand; you have to run gitweb with '--nproc=<n>'. Also if FCGI::ProcManager is not found, then the '--nproc=<n>' command line option is a no-op (does nothing).

>
> The special thank for getting rid of exit()!
You are welcome.
> 
> I'd like to propose the Git to have the Perl interface for common functions
> that can make it easy to create the bunch of tools like those made with
> (likely XS'ed) SVN::* namespace, e. g. git-svn.
>From what I remember from watching questions and discussion here on git

mailing list, the SVN::* Subversion bindings (from subversion-perl package) are serious PITA.

Git.pm started (by Petr Baudis) with XS parts, but because of lack of Perl hacker their compilation was unportable (IIRC it required support for -fPIC), and was therefore abandoned. The difficulty of creating Git::XS is exacerbated by the fact that there is no libgit to make Perl bindings againts, although hopefully GSoC 2010 project "Completing libgit2" would help.

Git.pm currently wraps git commands in a *portable* way; that was the reason behind creating it, to e.g. not have to write the same workarounds for ActiveState Perl. The other reason was to have safe way of invoking git commands. There are some utility functions there, but not much.

The "Gitweb caching" GSoC 2008 project[1] by Lea Wiemann included improvements to git Perl interface in the form of Git::Repo, Git::RepoRoot, Git::Object, Git::Commit and Git::Tag. They are available in Lea's repository[2], but were not merged into git core.

[1]: http://git.wiki.kernel.org/index.php/SoC2008Projects#Gitweb_caching [2]: http://repo.or.cz/w/git/gitweb-caching.git

>
> It makes me wonder why gitweb is packaged with Git but no Perl API seen:
If you ask why gitweb does not use Git.pm, the reason is twofold.

First, gitweb predates Git.pm. It also used safe form of invokeing git commands (list form of magic "-|" pipeline open) at least since b918298 (gitweb: Use list for of open for running git commands..., 2006-07-30), and was intended to run on POSIX (like e.g. "/" as path separator) and therefore ActiveState Perl workarounds were not needed.

Second, in a few places gitweb needs either to pipe output of git command to other command (to compressor in snapshot, and newly introduced to highlighter when syntax highlighting is turned on), or silence errors redirecting STDERR to /dev/null (in 'object' action to check if object exists). This is not yet supported in Git.pm.

Note that using IPC::Run for piping git command output to other command would be counter to gitweb's goal of minimal non-core dependencies.

> looks like its storage is simple enough 
> to realize all of that in PP. Don't just disappoint me saying that git is used
> to be exec()'uted on some of the gitweb calls. ;)

Gitalist[3], which started as port of gitweb to Catalyst web framework, uses Git::PurePerl, a pure Perl interface to Git repositories (which was mostly based on Grit, a git Ruby library, which includes a partial native Ruby implementation). Or used to use; there was some discussion whether to use Git::PurePerl or wrap git commands.

Note that Gitalist was based on IIRC 2008 version of gitweb, so while it includes features that gitweb doesn't have, the opposite also might be true (features in gitweb that Gitalist doesn't have).

Also performance matters for gitweb.
[3]: https://git.wiki.kernel.org/index.php/InterfacesFrontendsAndTools#Gitalist
-- 
Jakub Narebski
Poland
Previous: Peter VereshaginNext: Peter Vereshagin
Message 10 of 30 in “gitweb: Add support for running gitweb as FastCGI script”
  1. 0/2 gitweb: Add support for running gitweb as FastCGI scriptJakub Narebski, May 7, 2010
  2. 1/2 gitweb: Put all per-connection code in run() subroutineJakub Narebski, May 7, 2010
  3. 2/2 gitweb: Add support for FastCGI, using CGI::FastJakub Narebski, May 7, 2010
  4. 2/2 gitweb: Add support for FastCGI, using CGI::FastJakub Narebski, May 8, 2010
  5. Jakub NarebskiMay 8, 2010
  6. Eric WongMay 9, 2010
  7. Ævar Arnfjörð BjarmasonMay 9, 2010
  8. Jakub NarebskiMay 9, 2010
  9. Peter VereshaginMay 9, 2010
  10. Jakub NarebskiMay 9, 2010
  11. Peter VereshaginMay 10, 2010
  12. Jakub NarebskiMay 10, 2010
  13. Peter VereshaginMay 11, 2010
  14. Petr BaudisMay 11, 2010
  15. Jakub NarebskiMay 11, 2010
  16. Peter VereshaginMay 11, 2010
  17. Jakub NarebskiMay 11, 2010
  18. Peter VereshaginMay 13, 2010
  19. Ævar Arnfjörð BjarmasonMay 13, 2010
  20. Peter VereshaginMay 14, 2010
  21. Jakub NarebskiMay 14, 2010
  22. Peter VereshaginMay 14, 2010
  23. Jakub NarebskiMay 14, 2010
  24. Jakub NarebskiMay 14, 2010
  25. Peter VereshaginMay 15, 2010
  26. Jakub NarebskiMay 15, 2010
  27. Peter VereshaginMay 16, 2010
  28. Jakub NarebskiMay 18, 2010
  29. Petr BaudisMay 16, 2010
  30. Petr BaudisMay 15, 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.