How can I manage a long running process from a Rails app?
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?
I think you should have a look at delayed_job. It should do exactly what you are after.
Look into using background job plugin: http://backgroundrb.rubyforge.org/ It has good features and community support.