From: Tatsuhiko Miyagawa <miyagawa@gmail.com>
To: Jakub Narebski <jnareb@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 10:14:09 -0700 [thread overview]
Message-ID: <AANLkTimcEjYpwa2xFhnRtnQ4ImfqJrDzQJdpptKNoskh@mail.gmail.com> (raw)
In-Reply-To: <201005101826.10735.jnareb@gmail.com>
On Mon, May 10, 2010 at 9:26 AM, Jakub Narebski <jnareb@gmail.com> 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
next prev parent reply other threads:[~2010-05-10 17:14 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 ` gitweb, FastCGI and PSGI/Plack Jakub Narebski
2010-05-10 0:59 ` Tatsuhiko Miyagawa
2010-05-10 16:26 ` Jakub Narebski
2010-05-10 17:14 ` Tatsuhiko Miyagawa [this message]
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=AANLkTimcEjYpwa2xFhnRtnQ4ImfqJrDzQJdpptKNoskh@mail.gmail.com \
--to=miyagawa@gmail.com \
--cc=git@vger.kernel.org \
--cc=jgoerzen@complete.org \
--cc=jnareb@gmail.com \
--cc=juanjo@comellas.org \
--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).