开发者

How can I manage a long running process from a Rails app?

开发者 https://www.devze.com 2022-12-21 04:52 出处:网络
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 proce

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? 开发者_如何学PythonAlso, 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号