Live data from Hacker News

DotCloud releases support for Perl, aka Camel-as-a-Service

blog.dotcloud.com

51–53 of 53 posts

Re: DotCloud releases support for Perl, aka Camel-as-a-Service

#51

Earlier quoted context omitted.

> while (my $req = CGI::Fast->new) { myApp->run($req); } > Is there a handler/wrapper for that? Assuming that while loop is in your bootstrap FastCGI script, you can instead have an app.psgi (or whatever named) file with the content: use CGI::PSGI; my $app = sub { my $req = CGI::PSGI->new(shift); myApp->run_psgi($req) }; Now your new `run_psgi()` method should return the [ $status, $headers, $body ] array reference,…

I've read the entire advent for plack and started to port my app. - Why send back an array ref instead of using the CGI way? What is the advantage it brings? If I want my app to run in a simple FastCGI environment (with the CGI protocol), this will not be possible anymore so I will be dependent on the Plack suite or create 2 versions: PSCI enabled and not PSGI enabled (this will not be much but still, 2 is worst than…

> - Why send back an array ref instead of using the CGI way? What is the advantage it brings?

If you design a fibonacci() function, would you make it print the result to STDOUT, or return the result as a return value?

If the specification is to print to STDOUT, a web server needs to make a trick to capture the output using tie, PerlIO or anything else, just like FCGI.pm does, and that's inefficient.

> - Are all the $ENV variables available? (SCRIPT_NAME for example?)

http://search.cpan.org/~miyagawa/PSGI-1.03/PSGI.pod#The_Envi...

> I don't really see what advantages it will bring to framework like Mojolicious for example (they will certainly never ever used any Middleware stuff from the Plack namespace as this is at the heart of their policy

See this post by the Mojolicious author, how to use Plack middleware for ANY Mojolicious based apps http://blog.kraih.com/mojolicious-and-plack

Also for Dancer: http://advent.perldancer.org/2010/22

Re: DotCloud releases support for Perl, aka Camel-as-a-Service

#52

Earlier quoted context omitted.

I've read the entire advent for plack and started to port my app. - Why send back an array ref instead of using the CGI way? What is the advantage it brings? If I want my app to run in a simple FastCGI environment (with the CGI protocol), this will not be possible anymore so I will be dependent on the Plack suite or create 2 versions: PSCI enabled and not PSGI enabled (this will not be much but still, 2 is worst than…

> - Why send back an array ref instead of using the CGI way? What is the advantage it brings? If you design a fibonacci() function, would you make it print the result to STDOUT, or return the result as a return value? If the specification is to print to STDOUT, a web server needs to make a trick to capture the output using tie, PerlIO or anything else, just like FCGI.pm does, and that's inefficient. > - Are all the $…

> If the specification is to print to STDOUT, a web server needs to make a trick to capture the output using tie, PerlIO or anything else, just like FCGI.pm does, and that's inefficient.

I see. That's a valid point. So when I asked if by design the protocol would offer better performance, the answer is yes?

Is this inefficiency so bad that changing it to an array ref brings THAT much improvement though?

It was easy to change the output but I will have to create a thin wrapper around FastCGI/PSGI to make it transparent. something like this detection done in Mojo becomes necessary:

# PSGI (Plack only for now) return 'psgi' if defined $ENV{PLACK_ENV};

  # CGI
  return 'cgi' if defined $ENV{PATH_INFO} || defined $ENV{GATEWAY_INTERFACE};
well, that's not much work...

I'll continue porting the app and see how it behaves.

Thank you for your time.

Re: DotCloud releases support for Perl, aka Camel-as-a-Service

#53
post #33

Earlier quoted context omitted.

Likewise my company is 100% PSGI for the last year+, we're a mix of a good number of Catalyst and Dancer apps. We've had absolutely 0 problems here. PSGI stable, sane and the way you want to be doing things.

As both of you have a good experience of Plack/PSGI, could you sum up the benefit you got from using it?

If your app (or your framework) runs on Plack/PSGI you have a wide choice of server implementations. It will work under mod_perl, FastCGI and numerous other server environments.

Indeed if you write an app to run on DotCloud; you can also run the same app on your laptop, Phenona, any other server -- etc etc.

As someone else said (more politely), you'd have to be nuts to do an HTTP app now and not take advantage of it.

Post reply on HN