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, 16:26 UTC
Message-ID
<201005101826.10735.jnareb@gmail.com>
In-Reply-To
<t2n693254b91005091759ye577992y32d2b6a41d7d8c45@mail.gmail.com>
On Sun, May 9, 2010 at 17:59:11 -0700, Tatsuhiko Miyagawa wrote:
Show 7 quoted lines
> On Sun, May 9, 2010 at 4:05 PM, Jakub Narebski <jnareb@gmail.com> wrote:
> 
> > 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.
> 
> You don't need it - since you can just use Plack::App::WrapCGI.

It is simplest method, but I don't think it is best one from the performance and especially latency point of view.

As I understand it, CGI::Compile catches all STDOUT output of compiled CGI script, and passes it to PSGI layer (PSGI interface). That doesn't allow, I think, for serving request as it is generated. This might be important for actions (pages) such as 'snapshot', 'blob_plain' and 'patches', which simply dump output of external comand to STDOUT. If gitweb was written as PSGI app, or with PSGI-compliant web framework, it would return IO::Handle-like object.

Also I think that currently you can currently see in web browser page as it is being generated by gitweb (e.g. 'projects_list' page). This is impossible (I guess) with CGI::Compile.

There is also a problem that there is no way, I guess, to automatically reload / refresh app if underlying CGI script changes (a la "plackup -r").

Show 7 quoted lines
> > 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:
> 
> and the .fcgi wrapper can just use Plack::Loader, or the plackup
> executable with FCGI environment variable set, to DWIM.
Right, having gitweb.psgi PSGI wrapper, which can be run not only via
FCGI, but also on many other web servers, is certainly superior to
having gitweb.fcgi FastCGI wrapper, which allows to run gitweb as
FastCGI script (on FCGI server).
 
Show 10 quoted lines
> > 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.
> 
> Again, you still don't understand - once your CGI script is turned
> into PSGI, plackup can take over the web server interface, including
> the FastCGI interface. If you need .fcgi wrapper to be spawned from
> web servers, just put plackup command line call (or Plack::Runner or
> ::Loader) in the .fcgi script.
I didn't made myself clear here.

What I want, like I wrote in neighbour subthread, is for the FastCGI app that looks like this:

   use CGI::Fast;
   do_some_initialization();
   while ($q = new CGI::Fast) {
      process_request();  # it uses 'my $cgi = CGI->new()' inside
   }

to make PSGI application that runs do_some_initialization() only once, and returns converted-to-PSGI process_request() as PSGI subroutine (as PSGI $app).

-- 
Jakub Narebski
jnareb on #plack
Poland
Previous: Tatsuhiko MiyagawaNext: Tatsuhiko Miyagawa
Message 3 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.