example/example_helper.rb in asir-1.1.12 vs example/example_helper.rb in asir-1.2.0
- old
+ new
@@ -46,11 +46,16 @@
# In other words, we cannot rely on how Process.fork
# terminates within the block.
if ENV['ASIR_JRUBY_SPAWNED']
$stderr.puts " spawned server at #{__FILE__}:#{__LINE__}"
puts "*** #{$$}: server process"; $stdout.flush
- yield
+ begin
+ yield
+ rescue ::Exception => exc
+ $stderr.puts "*** #{$$}: service ERROR: #{exc.inspect}\n #{exc.backtrace * " \n"}"
+ raise exc
+ end
Process.exit!(0)
# dont do client, client is our parent process.
else
$stderr.puts " spawning at #{__FILE__}:#{__LINE__}"
ENV['ASIR_JRUBY_SPAWNED'] = "1"
@@ -62,10 +67,15 @@
end
else
# $stderr.puts " at #{__FILE__}:#{__LINE__}"
$server_pid = Process.fork do
puts "*** #{$$}: server process"; $stdout.flush
- yield
+ begin
+ yield
+ rescue ::Exception => exc
+ $stderr.puts "*** #{$$}: service ERROR: #{exc.inspect}\n #{exc.backtrace * " \n"}"
+ raise exc
+ end
end
end
sleep 1 # wait for server to be ready.
return false # do client.
end