FastCGI for Ruby? 
Author Message
 FastCGI for Ruby?

Hey there. A few weeks back, when I was searching for Ruby-related stuff, I
came across a reference to a 'fastcgi.so', and was interested. However, I
haven't seen/heard of it recently.

So I went and wrote a FastCGI implementation in Ruby. Is this the least bit
useful to anybody? If it is, I'll put it online someplace.

Also, I was wondering about ruby's current status as far as replacing something
like WebObjects. Basically, it needs a competent web application server and
something that can copy the functions of EOF (Enterprise Objects Framework) -- a
framework for mapping relational databases to objects. (Similar to perl's
Tangram).

I'm more than willing to roll up my sleeves and pitch in if somebody out there
has got something started. So far, I've come across IOWA and the Ruby Web
Application Framework, but haven't had a chance to go into either in detail.

--
Eli Green
Connection closed by foreign host.



Sat, 03 Jan 2004 07:05:24 GMT  
 FastCGI for Ruby?

Quote:

> Also, I was wondering about ruby's current status as far as replacing something
> like WebObjects. Basically, it needs a competent web application server and
> something that can copy the functions of EOF (Enterprise Objects Framework) -- a
> framework for mapping relational databases to objects. (Similar to perl's
> Tangram).

I've been working on exactly this. IOWA maps pretty closely to
WebObjects; it's a prototype and poorly documented, but people have had
some success with it and if you were interested in helping out I'd be
happy to flesh it out more (a FastCGI interface is one thing that would be
nice, but does mod_fcgi implement the multithreaded protocol yet?). The
EOF side is definitely lacking; I took a very quick run at it once but
we'd need to do some serious work to get it into usable shape.

IOWA is at http://beta4.com/iowa, and some initial EOF code is at
http://beta4.com/kansas.tgz - let me know what you think.

Cheers,
Avi



Sat, 03 Jan 2004 07:26:51 GMT  
 FastCGI for Ruby?

Quote:
> > Also, I was wondering about ruby's current status as far as replacing something
> > like WebObjects. Basically, it needs a competent web application server and
> > something that can copy the functions of EOF (Enterprise Objects Framework) -- a
> > framework for mapping relational databases to objects. (Similar to perl's
> > Tangram).

> I've been working on exactly this. IOWA maps pretty closely to
> WebObjects; it's a prototype and poorly documented, but people have had
> some success with it and if you were interested in helping out I'd be
> happy to flesh it out more (a FastCGI interface is one thing that would be
> nice, but does mod_fcgi implement the multithreaded protocol yet?). The
> EOF side is definitely lacking; I took a very quick run at it once but
> we'd need to do some serious work to get it into usable shape.

> IOWA is at http://beta4.com/iowa, and some initial EOF code is at
> http://beta4.com/kansas.tgz - let me know what you think.

> Cheers,
> Avi

Excellent! I took a slightly more detailed look at IOWA, and it looks pretty
slick (very similar to WO, which I like .. too bad ProjectBuilder doesn't
support ruby =).

As for mod_fcgi being multithreaded ... yes and no. Under Apache 1.xx, which
is forking, it's irrelevant wether it supports the multiplexing features of
the FastCGI protocol, since a new connection will need to be opened from every
forked process anyway. Under Apache 2.0, it will become more relevant to support
it.

One of my concerns (that I have yet to investigate) is wether ID's are properly
unique under mod_fastcgi currently ... if they're only unique to each apache
process, extra processing needs to be done to store the requests from each
accept()ed socket separate from each other.

How does mod_iowa compare to fastcgi? I just don't like duplicated effort. =)

--
Eli Green
Connection closed by foreign host.



Sat, 03 Jan 2004 11:52:48 GMT  
 FastCGI for Ruby?

Quote:

> Excellent! I took a slightly more detailed look at IOWA, and it looks pretty
> slick (very similar to WO, which I like .. too bad ProjectBuilder doesn't
> support ruby =).

Indeed... although one of the major goals of IOWA was to remove the need
for all the infrastructure WO uses (especially WO Builder - IOWA is much
happier than WO is with just emacs or Dreamweaver).

Quote:
> How does mod_iowa compare to fastcgi? I just don't like duplicated effort. =)

mod_iowa is a dead simple, just-get-it-working solution; it takes a very
similar approach to fcgi (open a socket, send over the request, get back
the response) without any of the niceties.  I haven't had any problems
with it, but using something more standard makes a lot of
sense.  Can you post your fcgi lib somewhere?

avi



Sat, 03 Jan 2004 12:08:37 GMT  
 FastCGI for Ruby?

Quote:


> > Also, I was wondering about ruby's current status as far as replacing something
> > like WebObjects. Basically, it needs a competent web application server and
> > something that can copy the functions of EOF (Enterprise Objects Framework) -- a
> > framework for mapping relational databases to objects. (Similar to perl's
> > Tangram).

> I've been working on exactly this. IOWA maps pretty closely to
> WebObjects; it's a prototype and poorly documented, but people have had
> some success with it and if you were interested in helping out I'd be
> happy to flesh it out more (a FastCGI interface is one thing that would be
> nice, but does mod_fcgi implement the multithreaded protocol yet?).

I've patched the latest IOWA to work with FastCGI.
May I send you the changes?

Regards,

  Michael

--
Michael Neumann
merlin.zwo InfoDesign GmbH
http://www.merlin-zwo.de



Sat, 03 Jan 2004 16:48:35 GMT  
 FastCGI for Ruby?

Quote:

> Hey there. A few weeks back, when I was searching for Ruby-related stuff, I
> came across a reference to a 'fastcgi.so', and was interested. However, I
> haven't seen/heard of it recently.

> So I went and wrote a FastCGI implementation in Ruby. Is this the least bit
> useful to anybody? If it is, I'll put it online someplace.

Yes, I'd like to see/use it.

Well, there is already a working FastCGI module for Ruby, but know what's missing it.

See http://www.ruby-lang.org/~knu/cgi-bin/cvsweb.cgi/lib/fcgi

I've written a short documentation for it:
  http://www.s-direktnet.de/homepages/neumann/fcgi-ruby-doc/fcgi.html

Apply also this patch to fcgi.c:

*** fcgi.c      Tue Jul 17 10:41:28 2001
--- fastcgi/devkit_2.2.0/fcgi-ruby-0.1/fcgi.c   Mon Feb 12 18:05:56 2001
***************
*** 104,110 ****
                rb_raise(eFCGIStreamProtocolError, "protocol error");\
                break;\
            case FCGX_PARAMS_ERROR:\
!               rb_raise(eFCGIStreamProtocolError, "parameter error");\
                break;\
            case FCGX_CALL_SEQ_ERROR:\
                rb_raise(eFCGIStreamCallSeqError, "preconditions are not met");\
--- 104,110 ----
                rb_raise(eFCGIStreamProtocolError, "protocol error");\
                break;\
            case FCGX_PARAMS_ERROR:\
!               rb_raise(eFCGIStreamParamsError, "parameter error");\
                break;\
            case FCGX_CALL_SEQ_ERROR:\
                rb_raise(eFCGIStreamCallSeqError, "preconditions are not met");\

Regards,

  Michael

--
Michael Neumann
merlin.zwo InfoDesign GmbH
http://www.merlin-zwo.de



Sat, 03 Jan 2004 16:48:40 GMT  
 FastCGI for Ruby?

Quote:



> > > Also, I was wondering about ruby's current status as far as replacing something
> > > like WebObjects. Basically, it needs a competent web application server and
> > > something that can copy the functions of EOF (Enterprise Objects Framework) -- a
> > > framework for mapping relational databases to objects. (Similar to perl's
> > > Tangram).

> > I've been working on exactly this. IOWA maps pretty closely to
> > WebObjects; it's a prototype and poorly documented, but people have had
> > some success with it and if you were interested in helping out I'd be
> > happy to flesh it out more (a FastCGI interface is one thing that would be
> > nice, but does mod_fcgi implement the multithreaded protocol yet?).

> I've patched the latest IOWA to work with FastCGI.
> May I send you the changes?

Please do!

Avi



Sat, 03 Jan 2004 16:50:35 GMT  
 FastCGI for Ruby?

Quote:

> I've patched the latest IOWA to work with FastCGI.

*** iowa.rb     Sun Feb 11 08:18:31 2001
--- ../myiowa/iowa.rb   Sat Jul  7 11:30:49 2001
***************
*** 38,43 ****
--- 38,81 ----


+
+ def Iowa.handleFCGIConnection(input, output)
+         url, junk = ENV["REQUEST_URI"].split("?")
+         if ENV["REQUEST_METHOD"] == "GET"
+           query = ENV["QUERY_STRING"]
+         else
+           query = input.read(ENV["CONTENT_LENGTH"].to_i)
+         end
+  
+         $stderr << "REQUEST_URI: #{ENV['REQUEST_URI']}\n"
+         $stderr << "QUERY_STRING: #{ENV['QUERY_STRING']}\n"
+
+         output << "Content-type: text/html\r\n\r\n"
+
+               params = {}
+       query.split(/[&;]/).each do |x|
+               key, val = x.split(/=/,2).collect{|x| unescape(x)}
+               if params.include?(key)
+                       params[key] += "\0" + (val or "")
+               else
+                       params[key] = (val or "")
+               end
+          end
+
+       begin
+                       stream = BufferedStream.new(output)
+
+               context = Iowa::Context.new(url, params, stream)
+               app.handleRequest(context)
+               stream.flush
+       rescue Exception
+               $stderr << "<p>#{$!}<ul>"
+               $stderr << $!.backtrace.collect {|i| "<li>#{i}</li>"}
+       end
+ end
+
+
+
  def Iowa.handleConnection(socket)
        urlLen = socket.recv(1)
        url = socket.recv(urlLen[0])
***************
*** 85,90 ****
--- 123,137 ----
        end
  end

+ def Iowa.run2(app_name)
+   require "fcgi"
+   FCGI.each_request do |f|
+     $stderr = f.err
+     handleFCGIConnection(f.in, f.out)
+   end
+ end
+
+
  def Iowa.app


Regards,

  Michael

--
Michael Neumann
merlin.zwo InfoDesign GmbH
http://www.merlin-zwo.de



Sat, 03 Jan 2004 20:33:32 GMT  
 FastCGI for Ruby?
How are you connecting with Ruby to databases such as Oracle.  

I very much want to join this project.  I want to use the fastcgi
module but don't know enough about how it works with Apache 2.x or
integrates with Ruby.

Also, I had a short stint with Apple web objects but thought it was
too much code to deal with for everyday web publishing.  I think your
approach of using Ruby to revisit the EOF framework is brilliant.

Would anyone like to write a book on the subject, or if someone wants
to sling the code, I would love to produce the documentation or a
small book.  I'm a firm believer in software is only as good as its
documentation.

I strongly believe that this very element will propel Ruby past
languages like Python, which although is a great language, remains
useless for most practical development tasks.  This is a perfect
compliment to Ruby.

--
ed



Sun, 04 Jan 2004 12:08:10 GMT  
 FastCGI for Ruby?

Quote:

>...

> I strongly believe that this very element will propel Ruby past
> languages like Python, which although is a great language, remains
> useless for most practical development tasks.  This is a perfect
> compliment to Ruby.

For those that know neither python nor Edward Wilson, I feel some
context would be useful.

Mr. Wilson believes that Java is also useless for "serious development
of any kind." If you know how prevalent Java is in the business world
(or how many large, successful database-oriented projects have been done
in Python) then you'll have a sense of how high the "usefulness" bar is
for Mr. Wilson. If Ruby happens not to measure up to this exacting
standard, I would encourage you not to take it personally...but watch
for him slamming Ruby in some other newsgroup.
--
Take a recipe. Leave a recipe.  
Python Cookbook!  http://www.ActiveState.com/pythoncookbook



Mon, 05 Jan 2004 01:09:11 GMT  
 FastCGI for Ruby?

Quote:

> How are you connecting with Ruby to databases such as Oracle.  

You can choose between:

  * DBI (database independet interface)
  * Oracle 7 module (works with Oracle 8/8i, too)
  * Ruby/ODBC

Regards,

  Michael

--
Michael Neumann
merlin.zwo InfoDesign GmbH
http://www.merlin-zwo.de



Mon, 05 Jan 2004 05:06:30 GMT  
 
 [ 11 post ] 

 Relevant Pages 

1. FastCGI for Ruby (an announcement, not a question)

2. Fastcgi and ruby

3. Ruby FastCGI bindings?

4. FastCGI library for Ruby

5. pthread trouble with ruby-opengl on FreeBSD (was: Re: [announcement] Ruby 3D Ruby)

6. Ruby books (Ruby NG FAQ, Ruby FAQ, home page)

7. FS FastCGI and IIS

8. FastCGI - any security?

9. FastCGI relay with Apache

10. FastCGI in VisualWorks

11. SmallEiffel+eSQL+FastCGI

12. How about a FastCGI interface for Eiffel?

 

 
Powered by phpBB® Forum Software