git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Cc: Eric Wong <normalperson@yhbt.net>
Subject: [PATCH] git-instaweb: Change how gitweb.psgi is made runnable as standalone app
Date: Sat, 26 Feb 2011 23:32:33 +0100	[thread overview]
Message-ID: <20110226223142.5944.31865.stgit@localhost.localdomain> (raw)

According to blog post "FindBin, __FILE__, $0 and PSGI woes"

  http://bulknews.typepad.com/blog/2011/02/findbin-__file__-0-and-psgi-woes.html

by Tatsuhiko Miyagawa, using 'if (__FILE__ eq $0)' in .psgi code
(to check if script was run from command line), is not supposed to work
since Plack 0.9971.

Replace it with one of proposed solutions; while at it return $app
explicitely, rather than implicitely by being a last expression.

This affects 'plackup' web server.


While at it cleanup whitespace.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 git-instaweb.sh |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/git-instaweb.sh b/git-instaweb.sh
index 10fcebb..86892f7 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -558,12 +558,14 @@ my \$app = builder {
 
 # make it runnable as standalone app,
 # like it would be run via 'plackup' utility
-if (__FILE__ eq \$0) {
+if (caller) {
+	return \$app;
+} else {
 	require Plack::Runner;
 
 	my \$runner = Plack::Runner->new();
 	\$runner->parse_options(qw(--env deployment --port $port),
-			       "$local" ? qw(--host 127.0.0.1) : ());
+	                        "$local" ? qw(--host 127.0.0.1) : ());
 	\$runner->run(\$app);
 }
 __END__

             reply	other threads:[~2011-02-26 22:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-26 22:32 Jakub Narebski [this message]
2011-02-27  1:56 ` [PATCH] git-instaweb: Change how gitweb.psgi is made runnable as standalone app Eric Wong

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=20110226223142.5944.31865.stgit@localhost.localdomain \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=normalperson@yhbt.net \
    /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).