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

hi, I was searching but could not find a howto. Looked also at the lighttpd docs for mod_fastcgi all are oriented towards php.
I also havent used fast cgi until now. So I was wondering which module should I use FCGI.pm or CGI::Fast
Then it is mentioned there are two ways to run fastcgi as spawning inside the lighty and spawning externally ? What is the difference, config & speedwise.
Then finally "bin-path" points should point to the script to run. Is there some special requirement for this script or it is simply a fastcgi while loop like this :
use FCGI; my $r = FCGI::Request; while ($r->Accept >= 0) { print "Content-type: text/html\n\n"; print 123; }
Currently I'm trying to adapt a Mason-lighty recipie

Replies are listed 'Best First'.
Re: setting lighttpd/fcgi/perl ?
by shmem (Chancellor) on Feb 02, 2008 at 10:43 UTC
    So I was wondering which module should I use FCGI.pm or CGI::Fast
    I'd go with CGI::Fast (which uses FCGI), since that gives you a request object as plain CGI does:
    use CGI::Fast; while( my $q = new CGI::Fast ) { print $q->header, $q->start_html, "123", $q->end_html; }

    If your concern is speed, you might want to use CGI::Minimal and FCGI and do the request object initialization according to CGI::Fast.

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re: setting lighttpd/fcgi/perl ?
by stvn (Monsignor) on Feb 02, 2008 at 17:52 UTC

    I recently released FCGI::Engine, which is meant to fill in what I see as the missing tools for Perl based Fast CGI development. It is modeled very heavily on Catalyst::Engine::FastCGI, but also includes a refactored FCGI::ProcManager as well. The SYNOPSIS section of FCGI::Engine pretty much says it all, although if you have any questions feel free to email me.

    I use Lighttpd as well, so it also includes some Lighttpd conf files that are used in the tests.

    While this module is only 0.02, I consider it pretty stable. For one thing, I "appropriated" all the really smart/hard bits from other more established modules (Catalyst::Engine::FCGI and FCGI::ProcManager) and just made them more generic (i.e. not tied to Catalyst). Also, this is currently being used to manage 6 different FCGI backends for a large $work project and has been running without issue for almost 4 months now.

    -stvn
      thanx , going to check it... and test.. definetly will ask more ;)
      from what I understand you set handler() function in a module to do the job.
      How do you normally do url-2->method dispatching ?

      and one more thing if I don't specify bin-path config option in lighttpd config then I have to start this handler-script separately with some options (and this is what they call in lighty docs runnging fcgi as external-fcgi-server), right ?
        from what I understand you set handler() function in a module to do the job.

        That is the default, you can change it with the handler_method constructor option. (NOTE: this was broke in any pre-0.03 release)

        How do you normally do url-2->method dispatching ?

        Usually the web framework I am using will take care of this (Catalyst, CGI::Application, etc). FCGI::Engine is simply about managing FCGI details for you, this kind of stuff is outside of the scope of this module.

        and one more thing if I don't specify bin-path config option in lighttpd config then I have to start this handler-script separately with some options (and this is what they call in lighty docs runnging fcgi as external-fcgi-server), right ?

        Yes, take a look at FCGI::Engine::Manager for a simple way to do this, the docs are still a little slim but if you look at the "020_basic_manager.t" test file and the contents of t/conf/ and t/scripts/ you will see how it is configured.

        -stvn