Issues with Plack::App::PSGIBin under plackup

25 views
Skip to first unread message

Mikolaj Kucharski

unread,
Oct 29, 2011, 2:57:12 PM10/29/11
to psgi-...@googlegroups.com
Hi,

Putting aside Apache and Plack topic from my previous email, here is
another issue which I do not understand.

System is OpenBSD 5.0 i386, p5-Plack-0.9980, PSGI app which I'm testing
is p5-Mojolicious-1.99.

I'm starting below PSGIBin ``router'' via plackup as follows:

env -i plackup -r -p 3500 -a /var/www/conf/pl.psgi

------------------------8<------------------------
#!/usr/bin/perl

use warnings;
use strict;

use Plack::App::PSGIBin;
use Plack::Builder;

my $app = Plack::App::PSGIBin->new(root => '/var/www/psgi-bin')->to_app;

builder {
mount '/' => $app;
};
------------------------8<------------------------


I've created very simple Mojolicious::Lite app:

http://pastebin.com/uXCq1CWB

from which the most important part is $self->app->home statement which
detects where the app is placed on the filesystem. At this stage I don't
know is this Plack or Mojolicious issue, but let me explain what I see.

Showing all above, let me go to the problem itself. I have exactly the
same script (above link to pastebin) in three different directories:


# cd /var/www/psgi-bin/
# ls -l tests?/
tests1/:
total 4
-rwxr-xr-x 1 root daemon 1085 Sep 27 22:22 all.pl

tests2/:
total 4
-rwxr-xr-x 1 root daemon 1085 Sep 27 22:22 all.pl

tests3/:
total 4
-rwxr-xr-x 1 root daemon 1085 Sep 27 22:22 all.pl


I'm starting packup (see above how I've executed it) and I'm opening my
browser to hit first all.pl file:


http://www1.kucharski.name:8080/tests1/all.pl

all is good, look at the ``home'' value, which correctly states
``/var/www/psgi-bin/tests1'', now lets hit another file:

http://www1.kucharski.name:8080/tests2/all.pl

and look at ``home'', then again go to:

http://www1.kucharski.name:8080/tests3/all.pl


You can see that ``home'' did *not* change when it should. This is my
issues. I'm learing Mojolicious and PSGIBin works perfectly (well,
should anyway) for me as I can put bunch of testing script to a
directories and see how they work, but ``app->home'' doesn't work as you
can see above.


- Can you advice where the problem can be?

- Do you think it's Plack or Mojolicious issue?


Cheers.


PS. Firewall does DNAT from port 8080 to my DMZ where plackup is
running on port 3500.

--
best regards
q#

Mikolaj Kucharski

unread,
Oct 29, 2011, 3:08:28 PM10/29/11
to psgi-...@googlegroups.com
First hit wins after restarting plackup(1). If I would start with
test3/all.pl then all other scripts would detect ($self->app->home) home
directory as they are in test3/ instead of their real directory.

--
best regards
q#

Tatsuhiko Miyagawa

unread,
Oct 29, 2011, 3:22:48 PM10/29/11
to psgi-...@googlegroups.com
On Sat, Oct 29, 2011 at 11:57 AM, Mikolaj Kucharski
<mik...@kucharski.name> wrote:

> You can see that ``home'' did *not* change when it should. This is my
> issues. I'm learing Mojolicious and PSGIBin works perfectly (well,
> should anyway) for me as I can put bunch of testing script to a
> directories and see how they work, but ``app->home'' doesn't work as you
> can see above.

I do understand the motivation but the way Mojolicious::Lite creates
namespaces and caches inside %ENV global variable, it doesn't work
nicely with multiple app environment like URLMap and PSGIBin.

> - Can you advice where the problem can be?
>
> - Do you think it's Plack or Mojolicious issue?

Look at the Mojolicious::Lite source code and you can easily locate
the use of %ENV.


--
Tatsuhiko Miyagawa

Mikolaj Kucharski

unread,
Oct 29, 2011, 4:31:07 PM10/29/11
to psgi-...@googlegroups.com

Just so I can be sure, do you mean line number 15?

https://metacpan.org/source/SRI/Mojolicious-2.15/lib/Mojolicious/Lite.pm#L15

--
best regards
q#

Tatsuhiko Miyagawa

unread,
Oct 29, 2011, 8:16:31 PM10/29/11
to psgi-...@googlegroups.com

Yep, and other MOJO_ environment variables assume that there is only one Mojolicious application per Perl interpreter.

Reply all
Reply to author
Forward
0 new messages