[dancer-users] Multiple apps with Plack and Apache

janet davis oscarjwoofer at gmail.com
Wed Jul 13 14:28:23 BST 2016


Thanks for both of your input, it has really helped a lot.

On Wed, Jul 13, 2016 at 12:25 AM, Chad Wallace <cwallace at lodgingcompany.com>
wrote:

> On Tue, 12 Jul 2016 22:07:56 +0100
> janet davis <oscarjwoofer at gmail.com> wrote:
>
> > The only problem is the uri_base doesn't point to the public
> > directory in my application root it points to / so no css/js etc.
> >
> > I have:
> > ProxyPass /app1 http://localhost:5000
> > ProxyPassReverse /app1 http://localhost:5000
> > And I can reach app1 on myserver.com/app1
> >
> > Is there anywhere in the config that I can specify the correct
> > uri_base per app?
>
> There's the behind_proxy config option (see Dancer2::Config).
>
> > I will try using Plack Builder with some example apps.  Are there any
> > performance implications if I run a lot of Dancer apps in this way
> > (15+) alongside my cgi scripts?  I don't want to go down this route
> > and then discover that I have issues with server resources.
>
> I'm guessing you'll get better performance with them combined.  They
> should at least use less memory that way, because the single process
> would load all modules only once, rather than loading one process per
> app, each with its own copy of perl, Plack, Dancer, Moo, etc.
>
> Adding the mounts with Plack::Builder probably doesn't add too much
> overhead.  From what I've seen, Plack and Dancer are both designed to
> perform and scale well.
>
> You could test both methods and compare the results.
>
>
> > On Tue, Jul 12, 2016 at 9:21 PM, Chad Wallace
> > <cwallace at lodgingcompany.com> wrote:
> >
> > > On Tue, 12 Jul 2016 19:55:31 +0100
> > > janet davis <oscarjwoofer at gmail.com> wrote:
> > >
> > > > Hi there,
> > > >
> > > > I have a web server running Apache with a single vhost that
> > > > serves a lot of Perl cgi scripts from cgi-bin.
> > > >
> > > > I've been trying out Dancer, which I really like, but I can't
> > > > figure out the best way to deploy apps in my Apache environment.
> > > > I want to keep my Apache cgi configuration to serve legacy
> > > > scripts but I want to start building new projects based on psgi
> > > > in something like Dancer.
> > > >
> > > > I want Apache to use www.myserver/cgi-bin/appname/script.pl for
> > > > old code (which currently works) and www.myserver/app1 for newer
> > > > Dancer based apps. Please don't think I'm being lazy by asking, I
> > > > have read the documentation and looked at the example for
> > > > deploying multiple apps via fcgi but I am still confused as I
> > > > have limited experience with Apache - I am working on that.
> > > > What's the best way to set this up, bearing in mind that I may
> > > > want to run say 10-15 Dancer apps from my server alongside my
> > > > cgi-scripts? Do I have to set up a vhost for each app?  I have
> > > > Apache::Plack::Handler but I'm not sure whether I should be using
> > > > Plack::Builder to mount my apps (which is mentioned in an older
> > > > Dancer Cookbook, but not the current deployment guide. Can
> > > > someone help me get on the right track please?
> > >
> > > I'm not sure it matches what you currently have in mind, but what I
> > > would do is set up www.myserver/app1 with mod_proxy to a standalone
> > > Plack/Dancer process for the app.  You would need something like
> > > this in your VirtualHost for each app:
> > >
> > >     ProxyPass  /app1  http://localhost:5000/app1
> > >
> > > You'd also have to manage starting, stopping and reloading each of
> > > your apps on its own, with a dedicated port, like 5000 in the line
> > > above.
> > >
> > > If you wanted to combine your apps into one, you can do that with
> > > Plack::Builder in a single app.psgi script.  Then you get the
> > > benefit of only having one script to start and stop, and one port.
> > > I currently do that with one of my apps to separate the
> > > AJAX-specific stuff, based on code I found in Dancer2::Cookbook[1]:
> > >
> > > #!/usr/bin/env perl
> > >
> > > use strict;
> > > use warnings;
> > >
> > > use FindBin;
> > > use lib "$FindBin::Bin/../lib";
> > >
> > > use Plack::Builder;
> > > use newtlc;
> > > use newtlc::API;
> > >
> > > builder {
> > >     mount '/'    => newtlc->to_app;
> > >     mount '/api' => newtlc::API->to_app;
> > > };
> > >
> > >
> > > [1]
> > >
> > >
> https://metacpan.org/pod/distribution/Dancer2/lib/Dancer2/Cookbook.pod#App-specific-feature
>
>
> --
>
> C. Chad Wallace, B.Sc.
> The Lodging Company
> http://www.lodgingcompany.com/
> OpenPGP Public Key ID: 0x262208A0
>
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20160713/e99e8238/attachment.html>


More information about the dancer-users mailing list