[Dancer-users] Problems mounting multiple webapps

Alberto Simoes ambs at perl-hackers.net
Mon Jun 13 16:06:32 CEST 2011


Hello,

Although what I'll say do not help you now, it will help you in the 
future :)

When updating Dancer to a more recent version all your
   Dancer::Request->new($env)
will need to be replaced by
   Dancer::Request->new(env => $env);

Now, hopefully somebody can help you with your current problem :)

On 13/06/2011 15:00, Takeshi OKURA wrote:
> 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.
>



More information about the Dancer-users mailing list