Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Serving multiple Plack apps

by sundialsvc4 (Abbot)
on Feb 10, 2015 at 14:12 UTC ( [id://1116182]=note: print w/replies, xml ) Need Help??


in reply to Serving multiple Plack apps

I’m a little bit confused by this thread.   Ordinarily, PSGI applications are run using Apache’s mod_fastcgi, mod_fcgi, or some other equivalent, and they are distinguished using AddHandler directives or otherwise, distinguished by virtual-host.   The web server dispatches the requests to the appropriate server process and maintains the pool of those processes.   This is true regardless of the programming language(s) being used.   You would distinguish the requests by virtual-hosts, somename.mycompany.com, and configure your internal DNS entries appropriately, and Apache (or nginix as the case may be) sends only the proper requests, directly to the proper service process pool.

Replies are listed 'Best First'.
Re^2: Serving multiple Plack apps
by soundX (Acolyte) on Feb 10, 2015 at 15:41 UTC

    Thanks for your thoughts guys, much appreciated.

    @Your Mother, thanks for the detailed example that's helpful.

    @sundialsvc4. This was part of my question, sorry I'm quite new to a lot of this so forgive my ignorance. I don't have a lot to do with our web server configs unfortunately it's done by our system admins. At the moment Apache is configured with a single vhost and ScriptAlias maps to cgi-bin.

    Ideally what I want is an easy to maintain option that allows me to write/deploy psgi apps in a similar way that I do with scripts in cgi-bin (although I know I can't just stick them in a directory and they'll work). I have read about using vhosts in Apache to deploy psgi apps, which is why I wondered whether Plack::App::URLMap was a viable alternative. I know I'm going to have to use something to handle requests so is creating vhosts for each app the way to do it?

      Vhosts have nothing to do with anything here.

      There are many ways to deploy this stuff but you cannot do anything beyond the plain CGI you already have without some modification to your webserver layer. If you think this is going to be a problem, then you’re stuck with CGI (which isn’t all bad, the ease of deployment is a perk). So, first things, first: ask your webadmin/team if they will allow a directive to run an app through apache. Again there are are a couple of different ways to do this, FastCGIExternalServer probably being the easiest (well, the most flexible anyway, otherwise you need to restart the web server to pick up application changes) for apache.

      If you do that, you can maybe run your whole CGI directory as a single psgi executable, like in my example. Some CGI code takes so many liberties that it can’t be run this way without Herculean efforts. It’s easy enough to try it as a test server, like in my example, and test it on an open port on your host. Your firewall might block it but most hosts have a lot of high ports open, like the default 5000 in the example. You would just substitute the real hostname for localhost. Note, running a live server, even a test server on a high port, can be risky (machine load, locks, security). You should never do it on a production box and make sure you have everyone’s blessing/approval before they find out what you’re up to when you accidentally lock the box with a runaway while() or something.

        Brilliant. Thanks for the pointers YM, that's exactly what I needed to get me going. I'm just trying out your example on a test server.
      A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1116182]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-28 22:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found