Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

is Plack really necessary?

by Anonymous Monk
on Apr 25, 2018 at 14:10 UTC ( #1213531=perlquestion: print w/replies, xml ) Need Help??

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

In a ngnix ,Starman,dancer set-up,where does Plack fit in? is it necessary for nginx to Starman communication? can you have a straight ngnix to dancer connection without Plack or Starman?

Replies are listed 'Best First'.
Re: is Plack really necessary?
by Your Mother (Archbishop) on Apr 25, 2018 at 17:24 UTC

    tl;dr: Yes.

    Plack is the namespace for an implementation of the PSGI standard. It is a more powerful modernization of and diversion from CGI. nginx wisely does not even support CGI (out of the box). That means you must use PSGI/Plack at least, though if you're feeling like redecorating your rooms in rubber you can use CGI beneath that. All modern Perl webframeworks (Catalyst, Mojolicious, Dancer2…) use PSGI as their interface layer because it is easily the best and most flexible way to do things today. Here is a simplistic but working set of code to run a toy app over PSGI through uWSGI/nginx.

    Code <-> Dancer2 <-> PSGI <-> uWSGI <-> nginx <-> Clients

    I recommend uWSGI over Starman.

      In your diagram of the simplistic deployment stack, I notice a distinct lack of layers labeled "Plack". Or is your overall point that "Plack" really just means "any arbitrary implementation of PSGI"?

        Yes. We only happen to have one and it lives in Plack:: but it's just a PSGI implementation/harness; just like CGI.pm is a CGI spec implementation. I'm glad miyagawa chose to keep the names separate though I suppose both approaches have some points of confusion.

      I see that ngnix can connect to Mojo's Hypnotoad without going through Plack pagi.what sort of protocol is used there?
      www.mind-it.info/2014/09/27/running-hypnotoad-behind-nginx/
        The configuration on the linked page shows nginx connecting to hypnotoad using proxy_pass, which connects to the back-end service using HTTP. This is also indicated by the backend having an http://... URL and the proxy_set_header X-Forwarded-Proto "http"; configuration setting.
Re: is Plack really necessary?
by robby_dobby (Hermit) on Apr 25, 2018 at 14:57 UTC
    Well, at least one of those frameworks won't work without Plack. Surely, you see that, don't you? Plack is what we call a "framework for frameworks", not exactly targeted at your "average" Perl developer, but there's nothing stopping them from using Plack in its barebones form.

    As an exercise, take a look at Plack's reverse dependencies

    Have fun, as always!

    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: perlquestion [id://1213531]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2022-05-25 20:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (90 votes). Check out past polls.

    Notices?