Collision of multiple Dancer2 apps using Plack::Handler::Apache2
Hello. Although the general answer seems to be: "yes, with Dancer2 it's possible to run multiple applications on the same server<https://github.com/PerlDancer/Dancer/issues/521>", I'm not able to do it :-/ I'm looking for the way to run 2 apps in *Dancer2* using * Plack::Handler::Apache2* without any trick as "using a proxy to different web servers", or "join two apps in one", etc. Is it possible?. I thought Dancer2 had solved it (instead of Dancer1). With the following configuration, I can only run one application correctly. If I start both, I have a mess ... # App1 <Location /app1> SetHandler perl-script PerlHandler Plack::Handler::Apache2 PerlSetVar psgi_app path_to_app1/bin/app.pl </Location> # App2 <Location /app2> SetHandler perl-script PerlHandler Plack::Handler::Apache2 PerlSetVar psgi_app path_to_app2/bin/app.pl </Location> Thanks a lot. Peco
Use 2 differents plackup start script and listen to a socket. Then use apache or nginx as a proxy. Le 16 sept. 2013 17:31, "Juan José 'Peco' San Martín" <jsanmartin@gmail.com> a écrit :
Hello.
Although the general answer seems to be: "yes, with Dancer2 it's possible to run multiple applications on the same server<https://github.com/PerlDancer/Dancer/issues/521>", I'm not able to do it :-/
I'm looking for the way to run 2 apps in *Dancer2* using * Plack::Handler::Apache2* without any trick as "using a proxy to different web servers", or "join two apps in one", etc.
Is it possible?. I thought Dancer2 had solved it (instead of Dancer1).
With the following configuration, I can only run one applicationcorrectly. If I start both, I have a mess ...
# App1 <Location /app1> SetHandler perl-script PerlHandler Plack::Handler::Apache2 PerlSetVar psgi_app path_to_app1/bin/app.pl </Location>
# App2 <Location /app2> SetHandler perl-script PerlHandler Plack::Handler::Apache2 PerlSetVar psgi_app path_to_app2/bin/app.pl </Location>
Thanks a lot. Peco
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Thank you. So it's not possible. The solution is to use a webserver as a proxy. :-( (like Dancer1...) Peco 2013/9/16 Celogeek San <me@celogeek.com>
Use 2 differents plackup start script and listen to a socket. Then use apache or nginx as a proxy. Le 16 sept. 2013 17:31, "Juan José 'Peco' San Martín" < jsanmartin@gmail.com> a écrit :
Hello.
Although the general answer seems to be: "yes, with Dancer2 it's possible to run multiple applications on the same server<https://github.com/PerlDancer/Dancer/issues/521>", I'm not able to do it :-/
I'm looking for the way to run 2 apps in *Dancer2* using * Plack::Handler::Apache2* without any trick as "using a proxy to different web servers", or "join two apps in one", etc.
Is it possible?. I thought Dancer2 had solved it (instead of Dancer1).
With the following configuration, I can only run one applicationcorrectly. If I start both, I have a mess ...
# App1 <Location /app1> SetHandler perl-script PerlHandler Plack::Handler::Apache2 PerlSetVar psgi_app path_to_app1/bin/app.pl </Location>
# App2 <Location /app2> SetHandler perl-script PerlHandler Plack::Handler::Apache2 PerlSetVar psgi_app path_to_app2/bin/app.pl </Location>
Thanks a lot. Peco
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Hi, On Mon, Sep 16, 2013 at 7:34 PM, Celogeek San <me@celogeek.com> wrote:
Use 2 differents plackup start script and listen to a socket. Then use apache or nginx as a proxy
That is what he was trying to avoid, and something that is said to be supported on the docs (at least on the Dancer2::Cookbook) :)). Yet, I think the documentation is misleading. What is supported is a single server with multiple apps, so its a sort of layering: for each request you test all the routes from all the apps. What the poster was looking for was true virtual hosting of multiple Dancer2 apps in the same process space, and that is still not supported transparently. You can do it with plack::builder though… Maybe creating a single App that uses Plack::Builder to split each app into it's own vhost, and then use Apache2 with that single app? Bye, -- Pedro Melo @pedromelo http://www.simplicidade.org/ xmpp:melo@simplicidade.org mailto:melo@simplicidade.org
Is it possible for Dancer to have a context-root (java term)? basically: /app1/request /app2/request This is how things are done in the java web world. Each web archive (containing an entire web application) has a context root binding (based on the file name, or set up explicitly as part of a bigger archive) and the web container (tomcat, jboss, etc.) route the request to the proper app based on that. On Mon, Sep 16, 2013 at 2:54 PM, Pedro Melo <melo@simplicidade.org> wrote:
Hi,
On Mon, Sep 16, 2013 at 7:34 PM, Celogeek San <me@celogeek.com> wrote:
Use 2 differents plackup start script and listen to a socket. Then use apache or nginx as a proxy
That is what he was trying to avoid, and something that is said to be supported on the docs (at least on the Dancer2::Cookbook) :)).
Yet, I think the documentation is misleading. What is supported is a single server with multiple apps, so its a sort of layering: for each request you test all the routes from all the apps.
What the poster was looking for was true virtual hosting of multiple Dancer2 apps in the same process space, and that is still not supported transparently.
You can do it with plack::builder though…
Maybe creating a single App that uses Plack::Builder to split each app into it's own vhost, and then use Apache2 with that single app?
Bye, -- Pedro Melo @pedromelo http://www.simplicidade.org/ xmpp:melo@simplicidade.org mailto:melo@simplicidade.org
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Hi, On Mon, Sep 16, 2013 at 8:07 PM, Slavik Goltser <slavikg@gmail.com> wrote:
Is it possible for Dancer to have a context-root (java term)?
basically: /app1/request /app2/request
See this: https://metacpan.org/module/Dancer2::Cookbook#Running-multiple-apps-with-Pla... I haven't tested this to make sure it works as expected though. Bye, -- Pedro Melo @pedromelo http://www.simplicidade.org/ xmpp:melo@simplicidade.org mailto:melo@simplicidade.org
On Mon, Sep 16, 2013 at 5:31 PM, Juan José 'Peco' San Martín < jsanmartin@gmail.com> wrote:
Hello.
Hi. Although the general answer seems to be: "yes, with Dancer2 it's possible
to run multiple applications on the same server<https://github.com/PerlDancer/Dancer/issues/521>", I'm not able to do it :-/
This relates directly to the ability to have multiple applications in the same Perl processor without serilalizers, responses and so forth stepping over each other. This has been tested and approved as proper. The reason is that Dancer1 has SharedData and other singletons while Dancer2 does not.
Is it possible?.
I've never tried. I would simply run a web server (such as Starman) and inside it use Plack::Builder with URLMapper.
I thought Dancer2 had solved it (instead of Dancer1).
Yes. The parts I noted were indeed solved. I have no idea what specific problem you're experiencing and you haven't provided any information to help us understand what you're seeing.
With the following configuration, I can only run one applicationcorrectly. If I start both, I have a mess ...
Could you please provide more information other than "I have a mess"? Example of your situation and the problem you're experiencing will help us find the problem. Sawyer.
Hi, I have 2 different Dancer apps (app1 and app2). Each one working very well on different servers under Apache and Plack::Handler::Apache2. Now, I would like put both applications in just one server, so I adjusted the Apache config just adding the two Location sections. If I use the first app, everything works, but when I try the second one, it seems that Dancer2 (with Plack::Handler::Apache2) still looks for the paths of the first app (so it fails because it can not find my app2 modules). Example (how to reproduce the behaviour) 0) Dancer 2.06 1) Adjust Apache config to add the Locations of the two apps # Apache location <Location /app1> SetHandler perl-script PerlHandler Plack::Handler::Apache2 PerlSetVar psgi_app /path/app1/bin/app.pl </Location> <Location /app2> SetHandler perl-script PerlHandler Plack::Handler::Apache2 PerlSetVar psgi_app /path/app2/bin/app.pl </Location> 2) Try app1 => it works! 3) Try app2 => fails with the next message: Error while loading /app2/app.pl: Can't locate App2.pm in @INC (@INC contains /path/app1/lib/ /usr/local....) Where App2 is the main module at (app2/lib/) called from app2/bin/app.plafter use Dancer2. Thank you 2013/9/16 sawyer x <xsawyerx@gmail.com>
On Mon, Sep 16, 2013 at 5:31 PM, Juan José 'Peco' San Martín < jsanmartin@gmail.com> wrote:
Hello.
Hi.
Although the general answer seems to be: "yes, with Dancer2 it's possible
to run multiple applications on the same server<https://github.com/PerlDancer/Dancer/issues/521>", I'm not able to do it :-/
This relates directly to the ability to have multiple applications in the same Perl processor without serilalizers, responses and so forth stepping over each other. This has been tested and approved as proper. The reason is that Dancer1 has SharedData and other singletons while Dancer2 does not.
Is it possible?.
I've never tried. I would simply run a web server (such as Starman) and inside it use Plack::Builder with URLMapper.
I thought Dancer2 had solved it (instead of Dancer1).
Yes. The parts I noted were indeed solved. I have no idea what specific problem you're experiencing and you haven't provided any information to help us understand what you're seeing.
With the following configuration, I can only run one applicationcorrectly. If I start both, I have a mess ...
Could you please provide more information other than "I have a mess"? Example of your situation and the problem you're experiencing will help us find the problem.
Sawyer.
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Hi, On Tue, Sep 17, 2013 at 10:36 AM, Juan José 'Peco' San Martín < jsanmartin@gmail.com> wrote:
I have 2 different Dancer apps (app1 and app2). Each one working very well on different servers under Apache and Plack::Handler::Apache2.
Now, I would like put both applications in just one server, so I adjusted the Apache config just adding the two Location sections.
If I use the first app, everything works, but when I try the second one, it seems that Dancer2 (with Plack::Handler::Apache2) still looks for the paths of the first app (so it fails because it can not find my app2 modules).
Example (how to reproduce the behaviour)
0) Dancer 2.06
1) Adjust Apache config to add the Locations of the two apps
# Apache location <Location /app1> SetHandler perl-script PerlHandler Plack::Handler::Apache2 PerlSetVar psgi_app /path/app1/bin/app.pl </Location>
<Location /app2> SetHandler perl-script PerlHandler Plack::Handler::Apache2 PerlSetVar psgi_app /path/app2/bin/app.pl </Location>
2) Try app1 => it works!
3) Try app2 => fails with the next message: Error while loading /app2/ app.pl: Can't locate App2.pm in @INC (@INC contains /path/app1/lib/ /usr/local....)
Where App2 is the main module at (app2/lib/) called from app2/bin/app.plafter use Dancer2.
Try this: create a merged.psgi file with this content: use Plack::Builder; use App1; use App2; builder { mount '/app1' => App1->dance; mount '/app2' => App2->dance; }; And then use it on Apache with: <Location /> SetHandler perl-script PerlHandler Plack::Handler::Apache2 PerlSetVar psgi_app /path/to/merged.psgi </Location> I have not tested this, I don't have a mod_perl2 at hand anymore, but it should work. Bye, -- Pedro Melo @pedromelo http://www.simplicidade.org/ xmpp:melo@simplicidade.org mailto:melo@simplicidade.org
What Pedro said works joining multiple apps in one. More info here.<http://search.cpan.org/~xsawyerx/Dancer2-0.09/lib/Dancer2/Cookbook.pod#Running_multiple_apps_with_Plack::Builder>Thank you! I have some issues with how each application locates resources. It seems that both are using the same paths for libraries or views. Suppose the next structure: pathX |__app1 |__app2 cd pathX *plackup -a app.psgi * Error while loading pathX/app.psgi: Can't locate App1.pm in @INC .... *plackup -I app1/lib -I app2/lib app.psgi * Route exception: pathX/views/index.tt is not a regular file or reference... How can I establish different environments (and paths) for each app?. Although this could be very useful, it's not the best solution when you want to keep one server with multiple and isolated apps (of different developers/teams). Anyway, thank you!. 2013/9/18 Pedro Melo <melo@simplicidade.org>
Hi,
On Tue, Sep 17, 2013 at 10:36 AM, Juan José 'Peco' San Martín < jsanmartin@gmail.com> wrote:
I have 2 different Dancer apps (app1 and app2). Each one working very well on different servers under Apache and Plack::Handler::Apache2.
Now, I would like put both applications in just one server, so I adjusted the Apache config just adding the two Location sections.
If I use the first app, everything works, but when I try the second one, it seems that Dancer2 (with Plack::Handler::Apache2) still looks for the paths of the first app (so it fails because it can not find my app2 modules).
Example (how to reproduce the behaviour)
0) Dancer 2.06
1) Adjust Apache config to add the Locations of the two apps
# Apache location <Location /app1> SetHandler perl-script PerlHandler Plack::Handler::Apache2 PerlSetVar psgi_app /path/app1/bin/app.pl </Location>
<Location /app2> SetHandler perl-script PerlHandler Plack::Handler::Apache2 PerlSetVar psgi_app /path/app2/bin/app.pl </Location>
2) Try app1 => it works!
3) Try app2 => fails with the next message: Error while loading /app2/ app.pl: Can't locate App2.pm in @INC (@INC contains /path/app1/lib/ /usr/local....)
Where App2 is the main module at (app2/lib/) called from app2/bin/app.plafter use Dancer2.
Try this: create a merged.psgi file with this content:
use Plack::Builder; use App1; use App2;
builder { mount '/app1' => App1->dance; mount '/app2' => App2->dance; };
And then use it on Apache with:
<Location />
SetHandler perl-script PerlHandler Plack::Handler::Apache2 PerlSetVar psgi_app /path/to/merged.psgi </Location>
I have not tested this, I don't have a mod_perl2 at hand anymore, but it should work.
Bye, -- Pedro Melo @pedromelo http://www.simplicidade.org/ xmpp:melo@simplicidade.org mailto:melo@simplicidade.org
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Maybe better to use nginx with it's backends instead of Apache? Or it's not possible in your situation? 2013/9/18 Juan José 'Peco' San Martín <jsanmartin@gmail.com>
What Pedro said works joining multiple apps in one. More info here.<http://search.cpan.org/~xsawyerx/Dancer2-0.09/lib/Dancer2/Cookbook.pod#Running_multiple_apps_with_Plack::Builder>Thank you!
I have some issues with how each application locates resources. It seems that both are using the same paths for libraries or views.
Suppose the next structure:
pathX |__app1 |__app2
cd pathX
*plackup -a app.psgi * Error while loading pathX/app.psgi: Can't locate App1.pm in @INC ....
*plackup -I app1/lib -I app2/lib app.psgi * Route exception: pathX/views/index.tt is not a regular file or reference...
How can I establish different environments (and paths) for each app?.
Although this could be very useful, it's not the best solution when you want to keep one server with multiple and isolated apps (of different developers/teams).
Anyway, thank you!.
2013/9/18 Pedro Melo <melo@simplicidade.org>
Hi,
On Tue, Sep 17, 2013 at 10:36 AM, Juan José 'Peco' San Martín < jsanmartin@gmail.com> wrote:
I have 2 different Dancer apps (app1 and app2). Each one working very well on different servers under Apache and Plack::Handler::Apache2.
Now, I would like put both applications in just one server, so I adjusted the Apache config just adding the two Location sections.
If I use the first app, everything works, but when I try the second one, it seems that Dancer2 (with Plack::Handler::Apache2) still looks for the paths of the first app (so it fails because it can not find my app2 modules).
Example (how to reproduce the behaviour)
0) Dancer 2.06
1) Adjust Apache config to add the Locations of the two apps
# Apache location <Location /app1> SetHandler perl-script PerlHandler Plack::Handler::Apache2 PerlSetVar psgi_app /path/app1/bin/app.pl </Location>
<Location /app2> SetHandler perl-script PerlHandler Plack::Handler::Apache2 PerlSetVar psgi_app /path/app2/bin/app.pl </Location>
2) Try app1 => it works!
3) Try app2 => fails with the next message: Error while loading /app2/ app.pl: Can't locate App2.pm in @INC (@INC contains /path/app1/lib/ /usr/local....)
Where App2 is the main module at (app2/lib/) called from app2/bin/app.plafter use Dancer2.
Try this: create a merged.psgi file with this content:
use Plack::Builder; use App1; use App2;
builder { mount '/app1' => App1->dance; mount '/app2' => App2->dance; };
And then use it on Apache with:
<Location />
SetHandler perl-script PerlHandler Plack::Handler::Apache2 PerlSetVar psgi_app /path/to/merged.psgi </Location>
I have not tested this, I don't have a mod_perl2 at hand anymore, but it should work.
Bye, -- Pedro Melo @pedromelo http://www.simplicidade.org/ xmpp:melo@simplicidade.org mailto:melo@simplicidade.org
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
participants (6)
-
Alexey Kolganov -
Celogeek San -
Juan José 'Peco' San Martín -
Pedro Melo -
sawyer x -
Slavik Goltser