0

I have a prototype application (RESTful web service database front-end) that is written using Dancer. As a prototype this runs fine under Apache with mod_proxy, and Dancer's routes work really nice.

My next step is to see if I can get this to scale a bit as some of the queries can be very slow and I don't want the slow queries blocking other requests.

I'd like to use rpms to manage the needed perl modules. For Dancer, this is no problem as CentOS-6 plus EPEL provide sufficient rpms to allow me to build/install Dancer and Dancer::Plugin::Database rpms. Trying to build Plack rpms isn't working nearly as well however due to a varietly of reasons, one of which is that some of the system modules are too low a version number (and no, overwriting the system rpms with higher version local builds is not considered an option).

EPEL does provide rpms for CGI::Emulate::PSGI and HTTP::Server::Simple::PSGI but I'm not seeing how to wrangle either one of them into a desired solution.

So, my question is: Is there a clean/maintainable way to get Dancer running on CentOS-6 with pre-forking? Barring that, how does one get Apache to play nicely with a local perl install (where I can use tools like cpanm to install things)?

Alan Haggai Alavi
  • 72,802
  • 19
  • 102
  • 127
gsiems
  • 3,500
  • 1
  • 22
  • 24
  • 1
    why not install a modern perl version with perlbrew ? – Miguel Prz Aug 03 '12 at 21:39
  • Any reason not to set up a local Perl environment with [local::lib](http://search.cpan.org/perldoc?local%3A%3Alib) or [perlbrew](http://perlbrew.pl/)? – matthias krull Aug 03 '12 at 21:41
  • MiguelPrz/mugen keichi-- I could do that, and have for other things (be nice not to have to). Additionally, I'm not sure how that will play with Apache (mt Apache-foo is not strong)-- is it a matter of setting the correct environment variables, does the perl version matter (thinking mod_perl here) or is that really a non-issue? – gsiems Aug 04 '12 at 04:04
  • You compile mod_perl against a concrete perl. So you install your own perl and compile mod_perl with it. Then in apache config you load your own mod_perl instead of the system one. – jira Aug 04 '12 at 14:56
  • @Miguel Prz -- Since you were the first to suggest perlbrew, which is the approach that I finally adopted (completely avoiding use of the system perl)-- would you care to make your comment an answer so that I may accept it? – gsiems Aug 29 '12 at 03:01

2 Answers2

0

If you want to restrict yourself to the packages shipped with CentOS, then you can run your Dancer app under mod_perl. There is a Plack adapter for mod_perl, so it is rather straightforward.

For example

<Location /myapp>
  SetHandler perl-script
  PerlHandler Plack::Handler::Apache2
  PerlSetVar psgi_app /var/www/html/myapp.example.com/app.psgi
</Location>
jira
  • 3,890
  • 3
  • 22
  • 32
  • @jira-- Except that Plack::Handler::Apache2 is part of Plack which won't cleanly build against the system perl libraries. – gsiems Aug 04 '12 at 16:38
  • Can the Dancer app be run as plain old CGI? Then you could run it under ModPerl::Registry – jira Aug 04 '12 at 17:32
  • @jira-- I don't know that you can run dancer as a plain CGI application. Additionally, I would think that the performance would be less than desirable for my application. – gsiems Aug 29 '12 at 03:03
  • The point was that then you run your CGI under ModPerl::Registry. That makes it run persistent - don't fear the word CGI in this case. – jira Aug 29 '12 at 07:06
0

I highly recommend you the use of perlbrew, and forget the system perl.

Miguel Prz
  • 13,718
  • 29
  • 42