Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FastCGI for Ruby?

0 views
Skip to first unread message

Eli Green

unread,
Jul 16, 2001, 7:05:24 PM7/16/01
to
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.


Avi Bryant

unread,
Jul 16, 2001, 7:26:51 PM7/16/01
to
On Tue, 17 Jul 2001, Eli Green wrote:

> 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

Eli Green

unread,
Jul 16, 2001, 11:52:48 PM7/16/01
to

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. =)

Avi Bryant

unread,
Jul 17, 2001, 12:08:37 AM7/17/01
to
On Tue, 17 Jul 2001, Eli Green wrote:

> 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).

> 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


Michael Neumann

unread,
Jul 17, 2001, 4:48:35 AM7/17/01
to
Avi Bryant wrote:
> On Tue, 17 Jul 2001, Eli Green wrote:
>
> > 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


Michael Neumann

unread,
Jul 17, 2001, 4:48:40 AM7/17/01
to
Eli Green wrote:
> 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");\

Avi Bryant

unread,
Jul 17, 2001, 4:50:35 AM7/17/01
to

Please do!

Avi


Michael Neumann

unread,
Jul 17, 2001, 8:33:32 AM7/17/01
to
Michael Neumann wrote:
> 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 ----

@@app = nil

+
+ 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
if @@app
@@app

Edward Wilson

unread,
Jul 18, 2001, 12:08:10 AM7/18/01
to
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

Paul Prescod

unread,
Jul 18, 2001, 1:09:11 PM7/18/01
to
Edward Wilson wrote:
>
>...

>
> 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


Michael Neumann

unread,
Jul 18, 2001, 5:06:30 PM7/18/01
to
Edward Wilson wrote:
> 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

0 new messages