[Dancer-users] Problems mounting multiple webapps

Takeshi OKURA okura3 at gmail.com
Mon Jun 13 16:00:49 CEST 2011


Hi.

I have read this threads. I tried mounting multiple webapps will work.
My test code app.psgi is below.
----------------------------------------------------------------------------------------
use Dancer ':syntax';
use Plack::Builder;

my $app1 = sub {
  my $env = shift;
  get '/' => sub { return "Hello App1"; };
  my $request = Dancer::Request->new($env);
  Dancer->dance($request);
};

my $app2 = sub {
  my $env = shift;
  get '/' => sub { return "Hello App2"; };
  my $request = Dancer::Request->new($env);
  Dancer->dance($request);
};

builder {
  mount "/app1" => builder{$app1};
  mount "/app2" => builder{$app2};
};
----------------------------------------------------------------------------------------

I invoked app.psgi with single worker.
plackup -s Starman --workers 1 -a app.psgi

I access /app1 and then /app2 in order.
Both times the result is same "Hello App1".

But I access /app2 and then /app1 in order.
Both times the result is same "Hello App2".

when I invoked app.psgi with 5 workers.
plackup -s Starman --workers 5 -a app.psgi

Access to /app1 and /app2 many times, the Result is mixed.
Access to /app1 returns "Hello App1" and "Hello App2" in random.
Access to /app2 returns "Hello App2" and "Hello App1" in random.

I'm worry that mouting multiple webapps seems does not work.

-- 
Takeshi OKURA


More information about the Dancer-users mailing list