Re: fastcgi with perl, php, etc
Sam Vilain <sam-s9IUA/[email protected]>
| Newsgroups | gmane.comp.web.fastcgi.devel |
|---|---|
| Message-ID | <[email protected]> |
Gustavo A. Baratto wrote:
>My problem is perl though... Basically, I want to do the same thing I did
>php to the other scripting languages. I want to pre-fork a few perl, python
>or tcl processes, and redirect the cgi requests to these pre-forked
>processes to improve speed.
>All the examples and docs I have seen over the net dont treat the script
>defined by FastCgiServer as a general 'perl server' as it is for php. I need
>'FastCgiServer /usr/bin/perl' to be the pre-forked interpreter for all .pl
>files.
>
>
You'll need to write a wrapper in Perl (that runs as root), something
along the lines of;
use FCGI;
my $socket = FCGI::OpenSocket(...);
my $request = FCGI::Request(...);
while ($request->accept()) {
($path, $script) = ($ENV{SCRIPT_NAME} =~ m{.*?/([^/]*)$});
if (fork()) {
# throw away the old handle
$request = FCGI::Request(...);
} else {
chdir($path);
$( = $) = (stat ".")[5];
$< = $> = (stat _)[4];
require './$script';
exit(0);
}
}
You'll need to experiment with the best way to handle the forking for
your application.
--
Sam Vilain, sam /\T vilain |><>T net, PGP key ID: 0x05B52F13
(include my PGP key ID in personal replies to avoid spam filtering)
___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/