[Backgroundrb-devel] cant fully capture child output

David Gurba david.gurba at gmail.com
Thu Mar 8 03:11:22 EST 2007


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 


More information about the Backgroundrb-devel mailing list