views:

186

answers:

1

I have a FastCGI Perl web app (written using CGI::Fast, but that should not matter), that I'd like to test in FastCGI mode.

What Perl module can I use to run FastCGI application (the module should install from CPAN, best if it didn't use extra libraries), so that can I point web browser e.g. to http://localhost:5000 to check if it work correctly?

Better, is there some Test::* module which allow to automatically test FastCGI applications, as FastCGI applications?


Added 06-07-2010:
It looks like there is no standalone FastCGI server in Perl; or at least I didn't found one. The FCGI / FastCGI related modules on CPAN that I have found are about writing FastCGI application, or connecting to existing FastCGI server.

+1  A: 

I don't know of a module that allows you to test Fast CGI applications specifically. To run a Fast CGI script for testing while developing I usually set up a small lighttpd server like this:

$HTTP["url"] =~ "^/[^/]*$" {
    fastcgi.server = (
        "/" => ((
            "socket" => "/tmp/myapp.sock",
            "bin-path" => "/path/to/my/fastcgi/script.pl",
            "check-local" => "disable",
            "allow-x-send-file" => "enable",
        )),
    )
}

# Use this if you also want to serve static files directly (not through your CGI app).
$HTTP["url"] =~ "^/static/.*$" {
    url.rewrite-once = ( "^/static/\(.*\)$" => "static/$1" )
}

You might also want to set the port to 5000 or anything higher than 1024 so you can run it as user. Save the file in your projects directory and run lighttpd like this:

/usr/sbin/lighttpd -f lighttpd.conf -D
jkramer