Michael Neumann wrote:

> I wrote:
>>1.
>>How would the complete FastCGI program look that can serve anything,
>>including Ruby programs that print their output?
>>Something that can fulfill requests such as
>>http://www.rubynewbies.com/~tobi/show_source.rb?file=show_source.rb&format=.xhtml
>>or
>>http://www.rubynewbies.com:9000/~tobi/show_source.rb?file=show_source.rb&format=.xhtml

[...]


> The obligatory "Hello World" FastCGI application looks like:
> 
>   require "fcgi"
> 
>   FCGI.each_request do |f|
>     $stdin = f.in
>     puts "Content-type: text/html"
>     puts
>     puts "<html><body>Hello World</body></html>"
>   end


Thanks so far; but I don't understand yet. Your examples, and the one on 
the FastCGI page all serve one thing (one option). I guess I could get 
those to run.
No if I got that right, I would use FastCGI to prevent that a new Ruby 
interpreter is started for each request to the server requesting a Ruby 
program.
So if I got that right too, I would use a single FastCGI program 
similiar to the three examples, with the main difference, that it can 
serve any Ruby programs output. Then the one FastCGI program is always 
running in one interpreter, and no additional interpreters are needed.

in pseudo code:

---all requests for Ruby programs go to that program---
require "fcgi"

FCGI.each_request do |f|
   # get(find&open) and read the requested file
   # if it's a Ruby program, check if allowed
   # pass the params and eval it
   # serve its' output
   # else serve its' content.
end
-----------------------end---------------------------

This way, I don't need to have FastCGI code in each and every Ruby 
program, but just one little FastCGI serverlein, that can handle any 
request.
(perhaps this is feasible, by passing the files' name as param; but 
perhaps it's not necessary.)

Or did I get that wrong?

If I use something like the examples for each and every Ruby program in 
my account, then wouldn't that result in a new intrpreter being started 
for each Ruby program, like before?

I'm sorry; I don't yet get the basic concept.

Or does FastCGI handle that internally? I serve each and every Ruby 
program using its' own little FastCGI servlet, and because FastCGI is 
magic, only one interpreter is started, ever? That would be nice too.

I would intensely appreciate further enlightenment.
(anyone writing a book on serverside ruby?)

Also: does FastCGI work well, generally?

Tobi

-- 
Tobias Reif
http://www.pinkjuice.com/myDigitalProfile.xhtml

go_to('www.ruby-lang.org').get(ruby).play.create.have_fun
http://www.pinkjuice.com/ruby/