I am in the process of using CGI::Application under FastCGI.
So far I have tried:
use CGI::Fast; while (my $q = new CGI::Fast){ my $app = new MyCGIApplication(QUERY => $q); # this is your CGI::App m +odule $app->run(); }
as proposed at link and link. What I found out is that this approach executes cgiapp_init() and setup() on *every* request (which isn't desireable as I load my templates there, establish caches etc and these steps should run only once!).

My second try was CGI::Application::FastCGI, which gets the flow of execution right (with executing setup and cgiapp_init only once), but seems to have some garbage-collection issues (which also the cpan bugtracker tells me).
As I understand it, this is due to the fact that CGI::Application::FastCGI does not create a new CGI::Application object for every request. To heal this, link suggests doing
$self->{__PARAMS} = {}; $self->header_type('header'); $self->header_props( {} );
in cgiapp_postrun() as a kind of garbage-collection. But what it does: it also wipes all my $self->params which I use as constants/configuration throughout the script. Any comments?


At link are talks about establish things like connecting the DB etc (which shoud normally happen in setup() or cgiapp_init() ) outsite the fcgi loop and then enter the Application (which I don't fully understand btw..)

Now, which way is the "CGI::Application way" of doing things and getting it right? Can somebody shed some light and give insight on how to get fcgi working on a script which should go, after an expensive init phase, into a proper runmode-loop.

In reply to CGI::Application under FastCGI (Guru advice needed) by isync

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.