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
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@engineyard.com -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273)
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
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
> > > > > > 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@engineyard.com > -- 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