# Cgi / fcgi?

**URL:** <https://www.ruby-forum.com/t/cgi-fcgi/86029>\
**Category:** Ruby\
**Created:** [February 19, 2007, 7:18am UTC](https://www.ruby-forum.com/t/cgi-fcgi/86029 "2007-02-19T07:18:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ktheory](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e480ec/32.png) [@ktheory](https://www.ruby-forum.com/u/ktheory)\
**Post date:** [February 19, 2007, 7:18am UTC](https://www.ruby-forum.com/t/cgi-fcgi/86029/1 "2007-02-19T07:18:13Z")

</div>

Forgive me for my newbiness. I’ve never had to deal with cgi’s before. I  
understand that fcgi is supposed to make cgi faster. But in the case of  
ruby, when i’m handling a request that was made to an fcgi. Do I handle  
it through the CGI apis? I don’t quite see how to handle one through  
fcgi? To me FCGI seems to be just the fcgi server?

For example, in my fcgi script. I’ve only been able to figure out how to  
grab request data through cgi = CGI.new. then accessing params and what  
not through that. Is that correct?

-thanks.

---

<div class="post-metadata">

**Author:** ![ktheory](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e480ec/32.png) [@ktheory](https://www.ruby-forum.com/u/ktheory)\
**Post date:** [February 19, 2007, 12:12pm UTC](https://www.ruby-forum.com/t/cgi-fcgi/86029/2 "2007-02-19T12:12:24Z")

</div>

On Mon, 19 Feb 2007 07:18:16 +0100, Aaron S.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> -thanks.

Your Ruby script needs to run a FCGI binding / listener / dispatcher /  
whatevertheheck too, which I think [1] provides its own mechanism for  
doing this, hopefully reasonably compatible with the standard CGI  
library.  
Considering you don’t mention doing that, I’m going out on a limb here  
and  
suspect the superior FCGI process degrades gracefully to regular CGI in  
your case.

David V.

[1] Can’t for the heck of it google up any documentation myself, and  
don’t  
quite feel like wading through the source in hopes there’s rdoc around.

---

<div class="post-metadata">

**Author:** ![ktheory](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e480ec/32.png) [@ktheory](https://www.ruby-forum.com/u/ktheory)\
**Post date:** [February 19, 2007, 8:07pm UTC](https://www.ruby-forum.com/t/cgi-fcgi/86029/3 "2007-02-19T20:07:35Z")

</div>

I’ve been looking at rails source code. The way I see it. I need to use  
something similar to the spawner, which creates the fcgi processes. Then  
inside of another script. Say gateway.fcgi. I trap all the different  
signals that come from an fcgi request.

it appears in the rails source that if the signal is USR1 he is then  
calling Dispatcher, which in turn executes the application and gets the  
response.

then in a lighttpd config, I can specify all three different process and  
how to handle them, or however many processes I spawn.

like so:

fastcgi.server = ( “.fcgi” =\>  
( “localhost-8000” =\> ( “host” =\> “127.0.0.1”, “port” =\> 8000 ) ,  
“localhost-8001” =\> ( “host” =\> “127.0.0.1”, “port” =\> 8001 ) ,  
“localhost-8002” =\> ( “host” =\> “127.0.0.1”, “port” =\> 8002 ) )  
)

make sense? Can it be easier then that? I’m thinking that the way rails  
sets this up is for multi threading so that one request doesn’t lock the  
application until that request is complete.

-thanks.
