I've written a small ruby cgi script which allows me to fork off a
rake process, which in turn forks off other processes interfacing with
subversion and ant mostly.

I have a long running rakefile and after a few minutes, it bails out
with the following error message:
./rake:28: unexpected return (LocalJumpError)
	from ./rake:21:in `chdir'
	from ./rake:21#!/usr/bin/ruby

Anyone got any ideas on what could cause this?


The actual cgi script follows:

require 'cgi'

cgi = CGI.new

unless cgi.has_key? 'rakefile' then
  cgi.out('text/plain') {'error: rakefile parameter not set'}
  return
end

BUILD_ROOT = '/opt/build/builds/' + cgi['rakefile']
target = cgi.has_key?('target') ? cgi['target'] : 'default'

unless File.exists? BUILD_ROOT then
  cgi.out('text/plain') {'error: rakefile ' + cgi['rakefile'] + ' not
found'}
  return
end

log = nil

Dir.chdir BUILD_ROOT do
  begin
    results = `rake #{target} 2>&1`
    log = results
    raise RuntimeError.new(log.chomp!) unless $?.success?
  rescue => x
    cgi.out('text/plain') {'error: ' + x + "\n" + log }
    return
  end
end

cgi.out('text/plain') {'done: ' + cgi['rakefile'] + "\n" + log}

--
Hans