Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

For "reasons", I'm loading a few Plack apps under mod_perl via Plack::Handler::Apache2. During a recent tidy up, I've been moving from one vhost entry per app, to a single vhost entry that uses Plack::App::URLMap, and adding an explicit load of all app modules pre-fork.

Loader app look like this

# find all modules in the apps' directories, and load them via Module: +:Load (so they are in mod_perl parent) # create URL mappings of the apps # %app_modules has app names as keys, and app namespaces as lavues APP: foreach my $app_name (keys %$app_modules) { my $uri_path = "/$app_name"; my $app_namespace = $app_modules->{$app_name}; $urlmap->mount( $uri_path => ${app_namespace}->to_app ); } $urlmap->to_app;

For two example Dancer apps like this, it works as expected:

package App1; use Dancer2; our $VERSION = '0.1'; get '/' => sub { return "THIS IS ROOT IN APP 1"; }; true;
But when I switch to the proper apps, I hit a problem. In the app, I have the code: use My::App qw(exported_method);

That app does not appear to load. I see no error thrown.

however, if I change the line to My::App->import('exported_method'); it works as expected.

I've been scratching my head over this for a few days now, and wondered if anyone has hit anything like this before, or has any pointers on where I should be digging to work this one out.

It looks like things start behaving if I remove the Module::Load code and don't preload everything (but loading the app this way doesn't preload all the app's dependancies).


In reply to Odd behavior when trying to preload Plack apps under mod_perl by cLive ;-)

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Domain Nodelet?
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this?Last hourOther CB clients
    Other Users?
    Others meditating upon the Monastery: (4)
    As of 2025-03-17 19:34 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      When you first encountered Perl, which feature amazed you the most?










      Results (56 votes). Check out past polls.