Re: gitweb, FastCGI and PSGI/Plack

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 10, 2010 at 9:26 AM, Jakub Narebski <jnareb@xxxxxxxxx> wrote:

> 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.

Yes, good point.

PSGI allows "streaming response interface", which gives you a writer
object to call ->write method, to implement the non-buffering output
from your application. (Of course, returning IO::Handle is another way
to do so, but that's "pull" style streaming, not "push" which is much
easier when you convert CGI applications).

It would still require you to rewrite some of the gitweb.cgi HTML
generation code, such as;

  # original
  my $cgi = CGI->new;
  print $cgi->header(...);
  print "<html>";
  print "<body>...";

into:

  # CGI::PSGI
  my $app = sub {
      my $env = shift;
      return sub {
          my $r = shift;
          my $cgi = CGI::PSGI->new($env);
          my $writer = $r->([ $cgi->header(...) ]);
          $writer->write("<html>");
          $writer->write("<body>...");
      }
  };

With some work to do the initialization and turn ->write call into a
callback, it should be possible to make one code do both the normal
CGI and PSGI.

> 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.

Correct, and possible with CGI::PSGI.

> 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").

Yes there is. "plackup -R" can specify the path containing your cgi
script to refresh whenever they're updated.

There's also "plackup -L Shotgun" to fork your application to get a
fresh copy in every request, handy for the development.


-- 
Tatsuhiko Miyagawa
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]