Nathan Leach
2006-Oct-17 02:22 UTC
Backgroundrb - how to pass a data file to worker from form
I am trying to initiate a background process with several parameters including a CSV file. Can anyone provide an example where a file is used as input for the background worker? Thanks, Nathan --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Ezra Zygmuntowicz
2006-Oct-17 02:27 UTC
Re: Backgroundrb - how to pass a data file to worker from form
On Oct 16, 2006, at 7:22 PM, Nathan Leach wrote:> > I am trying to initiate a background process with several parameters > including a CSV file. Can anyone provide an example where a file is > used as input for the background worker? > > Thanks, > NathanNathan- I would suggest just sending the filename to the worker and have the worker open the file and deal with the contents. -- Ezra Zygmuntowicz -- Lead Rails Architect -- ez-NLltGlunAUd/unjJdyJNww@public.gmane.org -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273) --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Nathan Leach
2006-Oct-17 02:54 UTC
Re: Backgroundrb - how to pass a data file to worker from form
Ezra, Thanks for the tip. The problem was that I was getting that "connection refused" when trying to open the file for reading. I found that passing in the file contents as an array works. Just wondering if there is a better way. I will look for ways around the connection error. Also, as a follow up (if you don''t mind sharing), what is the preferred method for ensuring that the background server is started/running at all times? The environment is Fedora Core 5. Thanks! Nathan On Mon, 2006-10-16 at 19:27 -0700, Ezra Zygmuntowicz wrote:> > On Oct 16, 2006, at 7:22 PM, Nathan Leach wrote: > > > > > I am trying to initiate a background process with several parameters > > including a CSV file. Can anyone provide an example where a file is > > used as input for the background worker? > > > > Thanks, > > Nathan > > > Nathan- > > > I would suggest just sending the filename to the worker and have the > worker open the file and deal with the contents. > > > -- Ezra Zygmuntowicz > -- Lead Rails Architect > -- ez-NLltGlunAUd/unjJdyJNww@public.gmane.org > -- Engine Yard, Serious Rails Hosting > -- (866) 518-YARD (9273) > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Nathan Leach
2006-Oct-17 15:16 UTC
Re: Backgroundrb - how to pass a data file to worker from form
On Mon, 2006-10-16 at 22:54 -0400, Nathan Leach wrote:> Ezra, > > Thanks for the tip. The problem was that I was getting that "connection > refused" when trying to open the file for reading. I found that passing > in the file contents as an array works. Just wondering if there is a > better way. I will look for ways around the connection error. > > Also, as a follow up (if you don''t mind sharing), what is the preferred > method for ensuring that the background server is started/running at all > times? The environment is Fedora Core 5. > > Thanks! > Nathan > > On Mon, 2006-10-16 at 19:27 -0700, Ezra Zygmuntowicz wrote: > > > > On Oct 16, 2006, at 7:22 PM, Nathan Leach wrote: > > > > > > > > I am trying to initiate a background process with several parameters > > > including a CSV file. Can anyone provide an example where a file is > > > used as input for the background worker? > > > > > > Thanks, > > > Nathan > > > > > > Nathan- > > > > > > I would suggest just sending the filename to the worker and have the > > worker open the file and deal with the contents. > > > > > > -- Ezra Zygmuntowicz > > -- Lead Rails Architect > > -- ez-NLltGlunAUd/unjJdyJNww@public.gmane.org > > -- Engine Yard, Serious Rails Hosting > > -- (866) 518-YARD (9273) > > > > > > > > > >All, I got this working using Ezra''s comments and the ''tempfile'' idea suggested in "Ruby Cookbook". Thought there might be others that want to accomplish similar things. I don''t want to clog the list, so here''s a summary... The form handler controller passes the multi-part file data to a temp file on the server file system, then passes the file dir/name to the background worker process. The worker re-reads the data and performs the main work...in this case updating a Postgresql database with about 100k records. If anyone wants details or code samples, please contact me off list. Also, if there are suggestions for improvements I could make, please let me know! Thanks, Nathan> > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---