Re: fastcgi with perl, php, etc
"Gustavo A. Baratto" <[email protected]>
| Newsgroups | gmane.comp.web.fastcgi.devel |
|---|---|
| Message-ID | <0b9001c486d2$f95afb40$6400a8c0@chivas> |
Thanks for reply....
Do I really have to fork?
What would be the drawbacks if I just use 'require' function to execute the
user script?
-----
#!/usr/local/bin/perl
use FCGI;
my $request = FCGI::Request( \*STDIN, \*STDOUT, \*STDERR, \%ENV);
my $count = 0;
while( $request->Accept() >= 0 ) {
do($ENV{PATH_TRANSLATED});
}
----
I want to avoid forking, as I wouldn't have much speed gain over normal cgi
scripts.
Another question... why do I have to throw away the old handle?
if (fork()) {
$request = FCGI::Request(...);
else
----- Original Message -----
From: "Sam Vilain" <sam-s9IUA/[email protected]>
To: "Gustavo A. Baratto" <[email protected]>
Cc: <[email protected]>
Sent: Thursday, August 19, 2004 3:47 PM
Subject: Re: [FASTCGI] fastcgi with perl, php, etc
> 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/