The biggest problem with what you want is that normal Rails runs fairly
stateless, especially as a CGI. With a CGI you’ll never get it to
work. I believe it’ll work in WEBrick, but I remember that WEBrick
seemed to also kill off threads like Rails was a CGI.
Under FastCGI or SCGI you could probably do it since they are long
running processes, but you’ll have to setup your thread(s) outside of
the Rails control, most likely with a global or similar (Singleton?)
Another option–if you need better control from your Rails
application–is to create a simple DRb API to your stand-alone
processor. This kind of gives you the best of all worlds.
The finaly problem I know you’ll run into is if this processor is
supposed to be unique on a machine–where only one runs–then you’ll
have huge problems in a clustering situation. Imagine it this way:
You have your wonderful processor thread working great with 1 SCGI
process. Now, you decide to speed up your app and start 4 SCGI
processor, which also means you have 4 of your little processing
In this situation, look to the DRb solution or just a simple cronjob.
Zed A. Shaw
On Tue, 29 Nov 2005 11:14:34 -0800