[Dancer-users] Problems mounting multiple webapps

Alex Kalderimis alex at flymine.org
Mon Jun 13 18:03:31 CEST 2011


On Mon, Jun 13, 2011 at 03:06:32PM +0100, Alberto Simoes wrote:
> 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);

I had noticed this from the latest devel on github - I should probably
add in a good error message for catching the old style of request
instantiation.

> 
> 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.
> >

I would try adding an appname to these codereferences:

  set appname => 'foo'; # Or similar

If I recall correctly, the current app is stored by name, and with
these both being unnamed they will clobber each other. I have multiple
webapps working happily on the same Starman server, and they do not
interfere with each other. 

> 
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users


More information about the Dancer-users mailing list