I have a Rails 2.0.2 application running with a postgresql db. The machine will receive data on a TCP port. I already have coded a working ruby multithreaded tcp server to receive the requests, but I need this code to run alongside my Rails app.
So I guess I need to know how to span a new process inside Rails, or how to create a worker thread that will run my threaded tcp server loop. My ruby tcp server could have access to ActiveRecord, but it’s not necessary (I can always create an http request, posting the received data to the original Rails server)
Why complicate things? Just run the applications — your TCP server and the Rails application — side by side.
Either pull the model tier (and ActiveRecord) into your TCP server (svn::externals or Piston might work well for that) and let the communication between the two applications happen through the database, or let the Rails application be the ‘master’ and communicate with it via HTTP as you suggest.
To turn a Ruby application into a Windows service, see the
win32-servicegem available from thewin32utilsproject: http://rubyforge.org/projects/win32utils/