fastcgi + eruby

J

J. D.

What is the best way to handle .rhtml (eruby) documents using fastcgi?

I'm using Linux, Apache2 and fcgi 0.8.4.

I'm trying to convert a site from mod_ruby to fastcgi so I can run some
comparison tests.

Converting .rbx was easy but I'm not sure how to best handle .rhtml.
 
P

Patrick May

What is the best way to handle .rhtml (eruby) documents using fastcgi?

I'm using Linux, Apache2 and fcgi 0.8.4.

I'm trying to convert a site from mod_ruby to fastcgi so I can run
some comparison tests.

Converting .rbx was easy but I'm not sure how to best handle .rhtml.

Maybe use the erb interpreter, and use fcgi instead of cgi? I think
that might work, but at the expense of having to insert a big loop into
all your rhtml templates. There's a cool continuation hack that matz
wrote to make cgi work with fcgi, without any code changes. But there
are some ruby bugs that affect continuations.

~ patrick
 
A

Ara.T.Howard

Maybe use the erb interpreter, and use fcgi instead of cgi? I think
that might work, but at the expense of having to insert a big loop into
all your rhtml templates. There's a cool continuation hack that matz
wrote to make cgi work with fcgi, without any code changes. But there
are some ruby bugs that affect continuations.

~ patrick

fastcgi works as a cgi out of the box without any code changes or
continuations? are you referring to something else, or the method used by
fcgi?

kind regards.

-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| When you do something, you should burn yourself completely, like a good
| bonfire, leaving no trace of yourself. --Shunryu Suzuki
===============================================================================
 
J

J. D.

Patrick said:
Maybe use the erb interpreter, and use fcgi instead of cgi? I think
that might work, but at the expense of having to insert a big loop into
all your rhtml templates. There's a cool continuation hack that matz
wrote to make cgi work with fcgi, without any code changes. But there
are some ruby bugs that affect continuations.

~ patrick

Thanks, you're right about erb!

Googling 'erb' instead of 'eruby' resulted in finding this:

http://pub.cozmixng.org/~the-rwiki/rw-cgi.rb?cmd=view;name=ERbMemo.en

The part about 'using as a library' on the page was particularly
helpful. I guess I can just include it inside the fcgi loop.
 
B

Brian Candler

What is the best way to handle .rhtml (eruby) documents using fastcgi?
I'm using Linux, Apache2 and fcgi 0.8.4.

I'm trying to convert a site from mod_ruby to fastcgi so I can run some
comparison tests.

Converting .rbx was easy but I'm not sure how to best handle .rhtml.

Tricky, because it's a different way of working.

If you change each .rhtml page into a separate fcgi script, then you will
have a separate persistent process for every page, which you probably don't
want if there are hundreds of pages.

You can write a simple fcgi program which reads a filename from the URL,
fetches and compiles the appropriate page (or gets it from a cache) and runs
it: e.g.

http://www.example.com/fcgi-bin/view/foo.rhtml

But then your URLs change. You could use mod_rewrite to chomp your URLs into
the appropriate new format though. Or you might be able to use "Action
handler-name" in the appropriate Directory / Location section.

I wouldn't just do it for the fun of it, or for making speed comparisons
(almost certainly the speed will be the same or slightly slower than
mod_ruby, since you're still doing the eruby work in Ruby, and you have the
extra overhead of communicating with a separate worker process rather than
the Apache httpd process running the Ruby itself)

I'd suggest you only do it if you're moving to an environment where
mod_fastcgi is available but mod_ruby isn't.

Cheers,

Brian.
 
M

Michael Neumann

Maybe use the erb interpreter, and use fcgi instead of cgi? I think
that might work, but at the expense of having to insert a big loop into
all your rhtml templates. There's a cool continuation hack that matz
wrote to make cgi work with fcgi, without any code changes. But there
are some ruby bugs that affect continuations.

Is this still true? I did some tests with the newest ruby-stable, and it
seems that these problems are gone. Can anybody confirm?

Regards,

Michael
 
P

Patrick May

Hi,

fastcgi works as a cgi out of the box without any code changes or
continuations? are you referring to something else, or the method
used by
fcgi?

The best case for continuations I have seen is demonstrated by Matz in
[ruby-talk:13428]

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/13428

It's quite a cool trick -- no each_request loop. I did experience a
few bugs in the combination of callcc and at_exit on darwin. I hope
they are fixed in the latest stable branch, because I think this is the
coolest.

Cheers,

Patrick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,142
Latest member
arinsharma
Top