I cant seem to get the io from a child process of a worker back to my
client. There most be something academic I''m missing :/. I looked at
examples in Pickaxe and Ruby PLEAC library ... and I believe the following
should work:
# called from within do_work...
def backup(repo)
logger.info(''SvnWorker backup repo ''+repo)
tmp = []
my_project = DIRS[:project_repos] + "/#{repo}"
dummyfile = ''backuptmp''
temp_file = "#{DIRS[:backups]}/#{dummyfile}"
svn_cmd = "svnadmin dump #{my_project} | gzip -9 >
#{temp_file}"
tmp << "piping to tmp"
results[:txt] = tmp
### i dont get the output between here ###
readme, writeme = IO.pipe
pid = fork {
# child
$stdout = writeme
readme.close
exec(svn_cmd)
}
# parent
Process.waitpid(pid,0)
writeme.close
while readme.gets do
results[:txt] = $_
end
### i dont get the output between here ###
readme.close
tmp << "piping done"
results[:txt] = tmp
tmp << "getting youngest"
results[:txt] = tmp
youngest = `svnlook youngest #{my_project}`
tmp << "youngest got"
results[:txt] = tmp
rev = "_rev#{youngest.chomp!}"
fname = [
"backup_#{repo}_",
Time.now.strftime(''%Y-%m-%d''),
"#{rev}",
''.gz''
]
destfile = "#{DIRS[:backups]}/#{fname.join}"
tmp << "destfile #{destfile}"
results[:txt] = tmp
FileUtils.mv(temp_file, destfile)
tmp << "backup file created at #{Time.now}"
results[:txt] = tmp
end
My previous messages shows taht all data before and after my comments is
received by the client.
Thanks (again) for any assistance, I''m pretty stumped. I keep plugging
away
at this and once I get these issues resolved the surrounding app is
completed :) [I tested this app prior to using a background job server ...
it just timed out on huge projects :/]
regards,
DavidG.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20070308/f72f6093/attachment.html
Ezra Zygmuntowicz
2007-Mar-08 08:48 UTC
[Backgroundrb-devel] cant fully capture child output
David- Backgroundrb is already doing a lot of forking and redirecting of IO streams. I think you are running into problems because you are forking again in a worker. You can''t really do that and still have things work properly. -Ezra On Mar 8, 2007, at 12:11 AM, David Gurba wrote:> I cant seem to get the io from a child process of a worker back to > my client. There most be something academic I''m missing :/. I > looked at examples in Pickaxe and Ruby PLEAC library ... and I > believe the following should work: > > # called from within do_work... > def backup(repo) > logger.info(''SvnWorker backup repo ''+repo) > tmp = [] > my_project = DIRS[:project_repos] + "/#{repo}" > dummyfile = ''backuptmp'' > temp_file = "#{DIRS[:backups]}/#{dummyfile}" > svn_cmd = "svnadmin dump #{my_project} | gzip -9 > #{temp_file}" > tmp << "piping to tmp" > results[:txt] = tmp > > ### i dont get the output between here ### > > readme, writeme = IO.pipe > pid = fork { > # child > $stdout = writeme > readme.close > exec(svn_cmd) > } > # parent > Process.waitpid(pid,0) > writeme.close > while readme.gets do > results[:txt] = $_ > end > > ### i dont get the output between here ### > > readme.close > tmp << "piping done" > results[:txt] = tmp > tmp << "getting youngest" > results[:txt] = tmp > youngest = `svnlook youngest #{my_project}` > tmp << "youngest got" > results[:txt] = tmp > rev = "_rev#{youngest.chomp!}" > fname = [ > "backup_#{repo}_", > Time.now.strftime(''%Y-%m-%d''), > "#{rev}", > ''.gz'' > ] > destfile = "#{DIRS[:backups]}/#{ fname.join}" > tmp << "destfile #{destfile}" > results[:txt] = tmp > FileUtils.mv(temp_file, destfile) > tmp << "backup file created at #{Time.now}" > results[:txt] = tmp > end > > My previous messages shows taht all data before and after my > comments is received by the client. > > Thanks (again) for any assistance, I''m pretty stumped. I keep > plugging away at this and once I get these issues resolved the > surrounding app is completed :) [I tested this app prior to using a > background job server ... it just timed out on huge projects :/] > > regards, > DavidG. > _______________________________________________ > Backgroundrb-devel mailing list > Backgroundrb-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/backgroundrb-devel-- Ezra Zygmuntowicz -- Lead Rails Evangelist -- ez at engineyard.com -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273)