git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Cc: Jakub Narebski <jnareb@gmail.com>
Subject: [RFC/PATCH 5/5] git-instaweb: Use new PSGI interface mode of gitweb
Date: Sat,  3 Mar 2012 18:57:03 +0100	[thread overview]
Message-ID: <1330797423-22926-6-git-send-email-jnareb@gmail.com> (raw)
In-Reply-To: <1330797423-22926-1-git-send-email-jnareb@gmail.com>

Now that gitweb supports PSGI interface itself, use it instead of
Plack::App::WrapCGI.

Note that gitweb as PSGI serves static files and ensures correct
handling of SIGCHLD, but the wrapper is still needed for logging,
mimetype handling (probably unnecessary), and selecting host and port.
It is now named gitweb-wrapper.psgi and not gitweb.psgi, though.

The advantage of previous version is that it uses persistent mode
(similar to FastCGI); important if $per_request_config is false or
coderef.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
Should make git-instaweb plackup mode better.

 git-instaweb.sh |   33 +++++++--------------------------
 1 files changed, 7 insertions(+), 26 deletions(-)

diff --git a/git-instaweb.sh b/git-instaweb.sh
index 01a1b05..58e142a 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -53,8 +53,8 @@ resolve_full_httpd () {
 		fi
 		;;
 	*plackup*)
-		# server is started by running via generated gitweb.psgi in $fqgitdir/gitweb
-		full_httpd="$fqgitdir/gitweb/gitweb.psgi"
+		# server is started by running via generated gitweb-wrapper.psgi in $fqgitdir/gitweb
+		full_httpd="$fqgitdir/gitweb/gitweb-wrapper.psgi"
 		httpd_only="${httpd%% *}" # cut on first space
 		return
 		;;
@@ -434,7 +434,7 @@ EOF
 plackup_conf () {
 	# generate a standalone 'plackup' server script in $fqgitdir/gitweb
 	# with embedded configuration; it does not use "$conf" file
-	cat > "$fqgitdir/gitweb/gitweb.psgi" <<EOF
+	cat > "$fqgitdir/gitweb/gitweb-wrapper.psgi" <<EOF
 #!$PERL
 
 # gitweb - simple web interface to track changes in git repositories
@@ -445,8 +445,7 @@ use strict;
 use IO::Handle;
 use Plack::MIME;
 use Plack::Builder;
-use Plack::App::WrapCGI;
-use CGI::Emulate::PSGI 0.07; # minimum version required to work with gitweb
+use Plack::Util;
 
 # mimetype mapping (from lighttpd_conf)
 Plack::MIME->add_type(
@@ -538,25 +537,7 @@ my \$app = builder {
 			\$app->(\$env);
 		}
 	};
-	# gitweb currently doesn't work with $SIG{CHLD} set to 'IGNORE',
-	# because it uses 'close $fd or die...' on piped filehandle $fh
-	# (which causes the parent process to wait for child to finish).
-	enable_if { \$SIG{'CHLD'} eq 'IGNORE' } sub {
-		my \$app = shift;
-		sub {
-			my \$env = shift;
-			local \$SIG{'CHLD'} = 'DEFAULT';
-			local \$SIG{'CLD'}  = 'DEFAULT';
-			\$app->(\$env);
-		}
-	};
-	# serve static files, i.e. stylesheet, images, script
-	enable 'Static',
-		path => sub { m!\.(js|css|png)\$! && s!^/gitweb/!! },
-		root => "$root/",
-		encoding => 'utf-8'; # encoding for 'text/plain' files
-	# convert CGI application to PSGI app
-	Plack::App::WrapCGI->new(script => "$root/gitweb.cgi")->to_app;
+	Plack::Util::load_psgi("$root/gitweb.cgi");
 };
 
 # make it runnable as standalone app,
@@ -574,8 +555,8 @@ if (caller) {
 __END__
 EOF
 
-	chmod a+x "$fqgitdir/gitweb/gitweb.psgi"
-	# configuration is embedded in server script file, gitweb.psgi
+	chmod a+x "$fqgitdir/gitweb/gitweb-wrapper.psgi"
+	# configuration is embedded in server script file, gitweb-wrapper.psgi
 	rm -f "$conf"
 }
 
-- 
1.7.9

  parent reply	other threads:[~2012-03-03 17:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-03 17:56 [RFC/PATCH 0/5] gitweb: Proof of concept of PSGI interface Jakub Narebski
2012-03-03 17:56 ` [RFC/PATCH 1/5] gitweb: Jump do DONE_REQUEST not DONE_GITWEB on error Jakub Narebski
2012-03-03 17:57 ` [RFC/PATCH 2/5] gitweb: Prepare for splitting gitweb Jakub Narebski
2012-03-03 17:57 ` [RFC/PATCH 3/5] gitweb: Enable running gitweb as PSGI app, via CGI::Emulate::PSGI Jakub Narebski
2012-03-03 17:57 ` [RFC/PATCH 4/5] gitweb.psgi: Allow passing arguments to Plack::Runner Jakub Narebski
2012-03-03 17:57 ` Jakub Narebski [this message]
2012-03-08 14:06 ` [RFC/PATCH 6/5] gitweb.psgi: Use installed static files, if they are available Jakub Narebski

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1330797423-22926-6-git-send-email-jnareb@gmail.com \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).