I posted this question before but got no response. I tried figuring it out myself to no avail. I have a long running task in my Rails app and unfortunately I get an ''execution expired'' error even though the task is not completed. Can I change the timeout value? Or any other tip for a long running task in a Rails app? The fate of the free world depends on it (almost). Thanks, Hunter
On Thu, 2005-09-22 at 15:46 -0700, Hunter Hillegas wrote:> I posted this question before but got no response. I tried figuring it out > myself to no avail. > > I have a long running task in my Rails app and unfortunately I get an > ''execution expired'' error even though the task is not completed. > > Can I change the timeout value? > > Or any other tip for a long running task in a Rails app? > > The fate of the free world depends on it (almost). > > Thanks, > HunterIs this with FastCGI? You basically have two options. Change your timeout value (mod_fastcgi settings... typically in your httpd.conf) Does this task absolutely need to be directly called from the web? If not, you might consider making this a script that can run via crontab or sit there waiting for you to call something (perhaps via DRb or something). -Robby -- /****************************************************** * Robby Russell, Owner.Developer.Geek * PLANET ARGON, Open Source Solutions & Web Hosting * Portland, Oregon | p: 503.351.4730 | f: 815.642.4068 * www.planetargon.com | www.robbyonrails.com *******************************************************/
David Heinemeier Hansson
2005-Sep-22 23:05 UTC
Re: Guru Needed - Long Running Tasks in Rails App
> Can I change the timeout value?This is controlled by your web server and possibly the FCGI configuration. For Apache/FCGI, you need to set something like: # Seconds to time out Timeout 300 # last parameter FastCgiServer /my/app/public/dispatch.fcgi -initial-env RAILS_ENV=production -processes 1 -idle-timeout 300 These two will give you a timeout of 300 seconds. Tweak as needed. -- David Heinemeier Hansson http://www.loudthinking.com -- Broadcasting Brain http://www.basecamphq.com -- Online project management http://www.backpackit.com -- Personal information manager http://www.rubyonrails.com -- Web-application framework
On 9/23/05, Hunter Hillegas <lists-HAWAbpnI61OZ1JSuHaJ1sQC/G2K4zDHf@public.gmane.org> wrote:> Or any other tip for a long running task in a Rails app?I''ve done this by running it in another process, using DRb to communicate between the FastCGI process and the external process, and using Ajax to provide feedback on the progress of the task. Leon
OK, I''ll take a stab. Have the controller fork. parent returns response. child does long running task. AJAX updates results page with status info, or just make the browser refresh automatically with a meta refresh: http://webdesign.about.com/cs/metatags/a/aa080300a.htm How to do this in Ruby? That''s not where I can help. :-) -- -- Tom Mornini On Sep 22, 2005, at 6:46 PM, Hunter Hillegas wrote:> I posted this question before but got no response. I tried figuring > it out > myself to no avail. > > I have a long running task in my Rails app and unfortunately I get an > ''execution expired'' error even though the task is not completed. > > Can I change the timeout value? > > Or any other tip for a long running task in a Rails app? > > The fate of the free world depends on it (almost). > > Thanks, > Hunter > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Yeah, I am using FastCGI... So, you''re saying I can change a mod_fastcgi setting? The error seemed to come from Rails so I wasn''t looking in mod_fastcgi - I will give it a check. No, the task doesn''t *need* to run via the Web. It does use a lot of the Rails API so I was just basically setting it up for crontab to hit a special URL every hour that processes the task. The problem was that even though I don''t care about what is returned by the browser, it was timing out and the task didn''t complete. Thanks for your suggestion - I''ll take a look at the mod_fastcgi settings.> From: Robby Russell <robby.lists-/Lcn8Y7Ot69QmPsQ1CNsNQ@public.gmane.org> > Organization: PLANET ARGON > Reply-To: <robby-/Lcn8Y7Ot69QmPsQ1CNsNQ@public.gmane.org>, <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > Date: Thu, 22 Sep 2005 15:59:36 -0700 > To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > Subject: Re: [Rails] Guru Needed - Long Running Tasks in Rails App > > On Thu, 2005-09-22 at 15:46 -0700, Hunter Hillegas wrote: >> I posted this question before but got no response. I tried figuring it out >> myself to no avail. >> >> I have a long running task in my Rails app and unfortunately I get an >> ''execution expired'' error even though the task is not completed. >> >> Can I change the timeout value? >> >> Or any other tip for a long running task in a Rails app? >> >> The fate of the free world depends on it (almost). >> >> Thanks, >> Hunter > > Is this with FastCGI? You basically have two options. Change your > timeout value (mod_fastcgi settings... typically in your httpd.conf) > > Does this task absolutely need to be directly called from the web? If > not, you might consider making this a script that can run via crontab or > sit there waiting for you to call something (perhaps via DRb or > something). > > -Robby > > -- > /****************************************************** > * Robby Russell, Owner.Developer.Geek > * PLANET ARGON, Open Source Solutions & Web Hosting > * Portland, Oregon | p: 503.351.4730 | f: 815.642.4068 > * www.planetargon.com | www.robbyonrails.com > *******************************************************/ > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
I just use script/runner to execute a Ruby method that sleeps for 10 seconds, looks for actions to perform, does them, then loops. Kyle Maxwell On 9/22/05, Hunter Hillegas <lists-HAWAbpnI61OZ1JSuHaJ1sQC/G2K4zDHf@public.gmane.org> wrote:> I posted this question before but got no response. I tried figuring it out > myself to no avail. > > I have a long running task in my Rails app and unfortunately I get an > ''execution expired'' error even though the task is not completed. > > Can I change the timeout value? > > Or any other tip for a long running task in a Rails app? > > The fate of the free world depends on it (almost). > > Thanks, > Hunter > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On Thu, 2005-09-22 at 15:59 -0700, Robby Russell wrote:> On Thu, 2005-09-22 at 15:46 -0700, Hunter Hillegas wrote: > > I posted this question before but got no response. I tried figuring it out > > myself to no avail.Have you considered using a FIFO? (Good on linux/unix) I''ve got a long running task over here. The web server writes all of the interesting bits of information into what it sees as a file, which is quite simple to implement on the client side. There is a never ending process just waiting to get activated by something writing to the FIFO. The FIFO server ''wakes up'' when data gets written to the FIFO. In my case, my server process simply reads what was written on the FIFO, decodes it, and then forks a new process to handle the long running part of the job. The main process then goes back to listening on the FIFO. I wrote the fifo handler several years ago in perl and found it to be quite easy. Of course, the way I''m using FIFO''s moves the job into a separate process batch process. It''s now entirely disconnected from the web server, and can run at a lower priority. I use e-mail to let users know when their long running task is complete, since the web interface is now ''disconnected''. I suppose the modern way would be to use AJAX to periodically poll the server to see if the task is complete, and then tell the user. http://www.linux.com/guides/lpg/node18.shtml> > > > I have a long running task in my Rails app and unfortunately I get an > > ''execution expired'' error even though the task is not completed. > > > > Can I change the timeout value? > > > > Or any other tip for a long running task in a Rails app? > > > > The fate of the free world depends on it (almost). > > > > Thanks, > > Hunter > > Is this with FastCGI? You basically have two options. Change your > timeout value (mod_fastcgi settings... typically in your httpd.conf) > > Does this task absolutely need to be directly called from the web? If > not, you might consider making this a script that can run via crontab or > sit there waiting for you to call something (perhaps via DRb or > something). > > -RobbyRegards, Rich -- Current Conditions in Des Moines, IA Few Clouds Temp 62.6F Winds out of the Northeast at 13mph
Thanks for all the great suggestions. I ended up re-writing a few bits and simply using the ''runner'' script and that is working great. Again, I appreciate the variety of suggested approaches. This is a great list to be on.> From: Rich Duzenbury <rduz-6Hh2x1qHOZDQT0dZR+AlfA@public.gmane.org> > Reply-To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > Date: Fri, 23 Sep 2005 00:06:48 -0500 > To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org>, <robby-/Lcn8Y7Ot69QmPsQ1CNsNQ@public.gmane.org> > Subject: Re: [Rails] Guru Needed - Long Running Tasks in Rails App > > On Thu, 2005-09-22 at 15:59 -0700, Robby Russell wrote: >> On Thu, 2005-09-22 at 15:46 -0700, Hunter Hillegas wrote: >>> I posted this question before but got no response. I tried figuring it out >>> myself to no avail. > Have you considered using a FIFO? (Good on linux/unix) > > I''ve got a long running task over here. The web server writes all of > the interesting bits of information into what it sees as a file, which > is quite simple to implement on the client side. There is a never > ending process just waiting to get activated by something writing to the > FIFO. > > The FIFO server ''wakes up'' when data gets written to the FIFO. In my > case, my server process simply reads what was written on the FIFO, > decodes it, and then forks a new process to handle the long running part > of the job. The main process then goes back to listening on the FIFO. > > I wrote the fifo handler several years ago in perl and found it to be > quite easy. > > Of course, the way I''m using FIFO''s moves the job into a separate > process batch process. It''s now entirely disconnected from the web > server, and can run at a lower priority. > > I use e-mail to let users know when their long running task is complete, > since the web interface is now ''disconnected''. I suppose the modern way > would be to use AJAX to periodically poll the server to see if the task > is complete, and then tell the user. > > http://www.linux.com/guides/lpg/node18.shtml > >>> >>> I have a long running task in my Rails app and unfortunately I get an >>> ''execution expired'' error even though the task is not completed. >>> >>> Can I change the timeout value? >>> >>> Or any other tip for a long running task in a Rails app? >>> >>> The fate of the free world depends on it (almost). >>> >>> Thanks, >>> Hunter >> >> Is this with FastCGI? You basically have two options. Change your >> timeout value (mod_fastcgi settings... typically in your httpd.conf) >> >> Does this task absolutely need to be directly called from the web? If >> not, you might consider making this a script that can run via crontab or >> sit there waiting for you to call something (perhaps via DRb or >> something). >> >> -Robby > > Regards, > Rich > > -- > Current Conditions in Des Moines, IA > Few Clouds > Temp 62.6F > Winds out of the Northeast at 13mph > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
On Thu, 2005-09-22 at 16:33 -0700, Hunter Hillegas wrote:> Yeah, I am using FastCGI... So, you''re saying I can change a mod_fastcgi > setting? The error seemed to come from Rails so I wasn''t looking in > mod_fastcgi - I will give it a check. > > No, the task doesn''t *need* to run via the Web. It does use a lot of the > Rails API so I was just basically setting it up for crontab to hit a special > URL every hour that processes the task. > > The problem was that even though I don''t care about what is returned by the > browser, it was timing out and the task didn''t complete. > > Thanks for your suggestion - I''ll take a look at the mod_fastcgi settings.You can run scripts from the shell and still use the Rails API. :-) http://wiki.rubyonrails.org/rails/pages/Environments#script -Robby -- /****************************************************** * Robby Russell, Owner.Developer.Geek * PLANET ARGON, Open Source Solutions & Web Hosting * Portland, Oregon | p: 503.351.4730 | f: 815.642.4068 * www.planetargon.com | www.robbyonrails.com *******************************************************/