8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/daimon_skycrawlers/timer.rb', line 8
def setup_shutdown_timer(queue_name_prefix, interval: 10)
timers = Timers::Group.new
timer = timers.after(interval) do
Process.kill(:INT, 0)
end
Thread.new(timers) do |t|
loop { t.wait }
end
ActiveSupport::Notifications.subscribe("consume_message.songkick_queue") do |*args|
event = ActiveSupport::Notifications::Event.new(*args)
queue_name = event.payload[:queue_name]
DaimonSkycrawlers.configuration.logger.debug("Reset timer: consume message #{queue_name}")
timer.reset
end
end
|