Sudheendra Panganamala
2010-Sep-17 00:49 UTC
Execute System command asynchronously in Controller->Action
My contoller -> action executes the ruby script on click of a button using System command. Ruby Script takes 30seconds to execute. If two users clicks the button same time in two separate browsers, second user execution will start after first user''s reqeust is completed. I need suggestion how to handle this ? Also is it possible to skip the script execution if it is already started by other user ? Thanks in advance.... -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Roberto Decurnex Gorosito
2010-Sep-17 13:21 UTC
Re: Execute System command asynchronously in Controller->Action
Hi, Two things about your problem ... 1st - The behavior that you are describing should only apply to your dev environment since you should be able to set up your production server to manage more than a single request at time. Anyways, there''s always a solution regardless of the environment like... 2nd - Try one of the backgrounders that ruby have right now like: backgroundrb - http://backgroundrb.rubyforge.org/ delayed_jobs - http://github.com/collectiveidea/delayed_job resque (my favorite :D) - http://github.com/defunkt/resque They will let you run your system calls as background processes without increasing your response time. Regards, -- Roberto On Sep 16, 9:49 pm, Sudheendra Panganamala <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> My contoller -> action executes the ruby script on click of a button > using System command. > Ruby Script takes 30seconds to execute. > > If two users clicks the button same time in two separate browsers, > second user execution will start after first user''s reqeust is > completed. > > I need suggestion how to handle this ? > > Also is it possible to skip the script execution if it is already > started by other user ? > > Thanks in advance.... > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.