lib/dispatch-rider/demultiplexer.rb in dispatch-rider-1.3.0 vs lib/dispatch-rider/demultiplexer.rb in dispatch-rider-1.3.1
- old
+ new
@@ -11,11 +11,10 @@
@queue = queue
@dispatcher = dispatcher
@error_handler = error_handler
@continue = true
@current_message = nil
- install_term_trap
end
def start
do_loop do
begin
@@ -26,26 +25,25 @@
end
end
self
end
- def stop
+ def stop(reason: nil)
@continue = false
+ if @current_message
+ logger.info "Got stop #{reason ? '(' + reason + ') ' : ' ' }while executing: #{message_info_fragment(@current_message)}"
+ end
end
private
- def install_term_trap
- SignalTools.append_trap('TERM') do
- logger.info "Got SIGTERM while executing: #{message_info_fragment(@current_message)}" if @current_message
- end
- end
-
def with_current_message(message)
- @current_message = message
- result = yield
- @current_message = nil
- result
+ begin
+ @current_message = message
+ yield
+ ensure
+ @current_message = nil
+ end
end
# This needs to return true/false based on the success of the jobs!
def dispatch_message(message)
with_current_message(message) do