views:

129

answers:

2

I'm building an app to learn Rails, and I'm not sure how to go about this.

I have a form, where the user enters some data. The data is validated, and a server side process should start ( the process may take from 5 minutes to 2 hours ). I'd like to be able to know the state of the process at all times and to be able to kill it. The thing I'm not sure how to do is starting the process. I know about system, backticks and all the ways to execute external commands from Ruby code ... the thing is, if I do this from a controller, will the server still process requests from other users? Also, should this be started from the controller? One of the things that I'll need to do is display the output of the process inside a page ( as it executes ).

How should I start & manage ( kill/restart ) a long running process in Rails? How would I do it in such a way that each user can start his own process?

A: 

Look into using background job plugin: http://backgroundrb.rubyforge.org/ It has good features and community support.

Zepplock
I can't listen on any ports. The only solution is a custom one.
Geo
I vote delayed_job, we just switched from backgroundrb to delayed_job
allenwei
+2  A: 

I think you should have a look at delayed_job. It should do exactly what you are after.

Jimmy Stenke
+1 for DelayedJob or Resque.
Simone Carletti
delayed_job is even supported on heroku.
Marc-André Lafortune