def spawn_application(options = {})
app_root = options["app_root"]
options = sanitize_spawn_options(options)
options["app_root"] = app_root
print_exceptions = options["print_exceptions"]
options["print_exceptions"] = false
begin
connect do |channel|
channel.write("spawn_application", *options.to_a.flatten)
result = channel.read
if result.nil?
raise IOError, "Connection closed"
end
if result[0] == 'exception'
e = unmarshal_exception(channel.read_scalar)
if print_exceptions && e.respond_to?(:child_exception) && e.child_exception
print_exception(self.class.to_s, e.child_exception)
elsif print_exceptions
print_exception(self.class.to_s, e)
end
raise e
else
return AppProcess.read_from_channel(channel)
end
end
rescue SystemCallError, IOError, SocketError => e
raise Error, "The framework spawner server exited unexpectedly: #{e}"
end
end