Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: Plack and apache child init phase (PlackChildInitHandler)

by Anonymous Monk
on May 01, 2014 at 07:36 UTC ( #1084575=note: print w/replies, xml ) Need Help??


in reply to Re^2: Plack and apache child init phase
in thread Plack and apache child init phase

Why do you ask?

So I can frame the question better, and because I can't really think of any other purpose for the hook :)

I think you'll find https://metacpan.org/pod/Plack::Handler::Apache2#STARTUP-FILE interesting, as well as https://metacpan.org/pod/Plack::Component#OBJECT-LIFECYCLE and especially https://metacpan.org/pod/Plack::Builder#INLINE-MIDDLEWARE

So you can create your own init_hook as an anonymous inline Plack::Middleware

builder { ... enable \&child_init_phase; $app; }; ... sub child_init_phase { my( $app ) = @_; ... ## your init stuff here $app; ## return app unmodified }
Thats your PlackChildInitHandler

Replies are listed 'Best First'.
Re^4: Plack and apache child init phase (PlackChildInitHandler)
by ysth (Canon) on May 01, 2014 at 08:26 UTC

    Thanks, I had read the Plack::Handler::Apache2 doc but not the others.

    I will give this a try, but...it's not clear to me how it is doing anything at child init time, not compile time.

    --
    A math joke: r = | |csc(θ)|+|sec(θ)| |-| |csc(θ)|-|sec(θ)| |

      I will give this a try, but...it's not clear to me how it is doing anything at child init time, not compile time.

      now you've confused me :) some more

      At what time, other than child init time, would any plackish webserver create an app object of your app and then wait for incoming requests?

      That is pretty much "child init time" in terms of PSGI ...

      So the app object is created, builder runs the "enable" callback, and then the webserver waits for requests to give to app

      Oh yeah, I see , it is no different than just doing it in the constructor :) except maybe slightly semantically different (if its not part of the app, then do nothing middleware seems appropriate)

      I think child_init_time is about knowing too much about the webserver

      PSGI is about apps, ::Middleware is about wrapping apps (daisy chain), and Plack::Handler is about connecting PSGI apps to webservers (hey random webserver run this app_

      I just can't see where child_init_time belongs as a PSGI/Plack concept ...

        At what time, other than child init time, would any plackish webserver create an app object of your app and then wait for incoming requests?

        Well, normally I want compilation to happen as early as possible; in a preforking server, this is at startup. child init is after that, whenever a new child is forked, but before actually waiting for incoming requests.

        --
        A math joke: r = | |csc(θ)|+|sec(θ)| |-| |csc(θ)|-|sec(θ)| |

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2019-12-09 17:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?