temporal has asked for the wisdom of the Perl Monks concerning the following question:

Monks,

I have developed multiple Catalyst applications and right now they are all separate standalone apps. I'd really like to bring all of these apps under a single point of access.

Currently, I have my apps running individually on different ports deployed using Catalyst's built-in HTTP server. This is not really that pretty or efficient and I don't like having so many open ports. Ideally, I'd like to run them all under port 80 and manage them all through a single instance of Catalyst.

Now, I know that I could just merge all of their files/directories under one mega-project. This would be painfully unorganized, as the different pieces of all the different apps would be completely mixed up. Not to mention I would have to fix the logic for overlapping controller methods. This would quickly become difficult to manage.

Is it possible to keep my apps distinct but run them under a single Catalyst built-in HTTP server? Or perhaps it is time to graduate to a dedicated server application (nginx) and use different virtual hosts... I would miss the portability of the built-in server.

Replies are listed 'Best First'.
Re: Combine Multiple Catalyst Applications
by Your Mother (Archbishop) on Apr 13, 2012 at 19:49 UTC

    Helpful reading–

    # If you're not reasonably up to date- sudo cpanm Plack Catalyst Catalyst::Devel

    Full steps for testing two Cat apps in one server

    # *nix centric. mkdir cattest cd cattest catalyst.pl OneFish catalyst.pl TwoFish vi^W emacs a-one-an-a-two-a.psgi # But I keed!

    a-one-an-a-two-a.psgi

    #!/usr/bin/env perl use strict; use Plack::Builder; use FindBin; use lib "$FindBin::Bin/OneFish/lib", "$FindBin::Bin/TwoFish/lib"; use OneFish; use TwoFish; my $app = builder { mount "/two" => TwoFish->psgi_app(@_); mount "/" => OneFish->psgi_app(@_); # Root needs to be last or it'll eat others. };

    Run, dog, run

    env CATALYST_DEBUG=0 plackup a-one-an-a-two-a.psgi HTTP::Server::PSGI: Accepting connections at http://0:5000/

    Visit http://localhost:5000/ (or whatever name/ip your box prefers) and http://localhost:5000/two/ and don't forget to tip your servers.

    Caveat: this might lead to entangling or making cross-dependent coding choices which would be bad. Make an effort to keep things compartimental. Abstract and separate commonality like sessions/auth. If each app can't run alone after you're done, you might as well have rolled them all into one to start.

      Thanks! Exactly what I was looking for (and entertaining to boot). I was peripherally aware of Plack. Now I have become FULLY aware. O_O

      Very handy.

        Get to know Plack . . . very, very, very well.

      Is there a way to mount by domain name instead of path? I have multiple apps that I need to differentiate by which domain name is requesting them.

        Pretty sure there is; with a middleware mapper. Why don’t you post a new question/thread though so it’s not stuck down here?

Re: Combine Multiple Catalyst Applications
by Anonymous Monk on Apr 14, 2012 at 02:40 UTC