in reply to PSGI / Plack

It is Awesomeness™ ... and here’s (I think) why.

For the past five months I’ve been dealing with a legacy application that was “wedged into” the Apache server by means of mod_perl.   This made perfect sense in 1998 or so when this system was first put on the drawing board, but it does not make sense now.   Plack enabled me to retrofit the application, with only a small number of very targeted changes, to run in FastCGI.   Or, in any and every other deployment alternative that Plack supports.

Plack is like a mechanical “slip joint” for web applications.   Plack provides a series of server-specific interfaces, all of which support a single, server-independent API.   By writing your application in this way, you are able to switch it to many different deployment strategies without re-writing it.

It certainly is convenient that one of those “deployment strategies” is the command-line plackup command.   This runs the app on your command-line, and yet your app cannot (unless it wants to...) see the difference.   (plackup is “just another Plack-compatible interface.”)

Replies are listed 'Best First'.
Re^2: PSGI / Plack
by davido (Cardinal) on Aug 17, 2011 at 02:56 UTC

    So here's something that I've been meaning to clarify for myself.

    If I write an application for Mojolicious, which itself supports CGI, FastCGI, a Mojolicious-bundled server, and Plack, and I deploy the application with FastCGI, is there any benefit to pulling back and redeploying it on top of Plack? My understanding of the Mojolicious framework is that it should just work, regardless of the back end, as long as the back end happens to be based on either CGI, FastCGI, or Plack.

    I understand that if I were to move to a different environment not supported directly by my framework Plack would be beneficial, as it supports a greater variety of servers and back-ends. But it seems to me it's one of those things that's available when I need it, and as long as I stick to a framework that supports it I can always migrate when I do need it.

    Is this reasonable?


    Dave

      Is this reasonable?

      Yes, it is reasonable.

      Or to put it another way ... when creating a new web app, you should not use a low-level API like CGI, FastCGI or mod_perl. Instead you should either use a framework (Catalyst, Dancer, Mojolicious etc) or for very small projects, code to the PSGI API instead.