# [PATCH] git-instaweb: Change how gitweb.psgi is made runnable as standalone app

2 messages from 2011-02-26 to 2011-02-27. Participants: Jakub Narebski, Eric Wong.
Thread: https://gitlist.dev/t/26611

## Jakub Narebski, 2011-02-26 22:32

Subject: [PATCH] git-instaweb: Change how gitweb.psgi is made runnable as standalone app
Message-ID: <20110226223142.5944.31865.stgit@localhost.localdomain>
URL: https://gitlist.dev/e/20110226223142.5944.31865.stgit%40localhost.localdomain

```
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__

```

## Eric Wong, 2011-02-27 01:56

Subject: Re: [PATCH] git-instaweb: Change how gitweb.psgi is made runnable as standalone app
Message-ID: <20110227015648.GA26643@dcvr.yhbt.net>
URL: https://gitlist.dev/e/20110227015648.GA26643%40dcvr.yhbt.net
In-Reply-To: <20110226223142.5944.31865.stgit@localhost.localdomain>

```
Jakub Narebski <jnareb@gmail.com> wrote:
> Signed-off-by: Jakub Narebski <jnareb@gmail.com>

All looks reasonable to me (untested)

Acked-by: Eric Wong <normalperson@yhbt.net>

```
