Module: DaimonSkycrawlers::Timer
- Defined in:
- lib/daimon_skycrawlers/timer.rb
Overview
Name space for timer
Class Method Summary collapse
-
.setup_shutdown_timer(queue_name_prefix, interval: 10) ⇒ Timers::Group
Setup timer for shutdown.
Class Method Details
.setup_shutdown_timer(queue_name_prefix, interval: 10) ⇒ Timers::Group
Setup timer for shutdown
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/daimon_skycrawlers/timer.rb', line 17 def setup_shutdown_timer(queue_name_prefix, interval: 10) timers = Timers::Group.new timer = timers.after(interval) do if block_given? yield else Process.kill(:INT, 0) end 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 timers end |