lib/main_loop/dispatcher.rb in main_loop-0.1.2.16825 vs lib/main_loop/dispatcher.rb in main_loop-0.1.2.16854

- old
+ new

@@ -12,10 +12,11 @@ super() @bus = bus @timeout = timeout @handlers = [] @logger = logger || Logger.new(nil) + @exit_code = 0 end def reap(statuses) statuses.each do |(pid, status)| reap_by_id(pid, status) @@ -55,10 +56,15 @@ handlers.each(&:term) end end end + def crash + @exit_code = 3 + term unless terminating? + end + def tick log_status if logger.debug? return unless terminating? try_exit! @@ -82,10 +88,10 @@ def try_exit! synchronize do return unless handlers.all?(&:finished?) logger.info('All handlers finished exiting...') - status = handlers.all?(&:success?) ? 0 : 1 + status = handlers.all?(&:success?) ? @exit_code : 1 exit status end end # :nocov: