module DatadogBackup::ThreadPool

Constants

TPOOL

Public Class Methods

shutdown(logger) click to toggle source
# File lib/datadog_backup/thread_pool.rb, line 20
def self.shutdown(logger)
  logger.fatal 'Shutdown signal caught. Performing orderly shut down of thread pool. Press Ctrl+C again to forcibly shut down, but be warned, DATA LOSS MAY OCCUR.'
  TPOOL.shutdown
  TPOOL.wait_for_termination
rescue SystemExit, Interrupt
  logger.fatal 'OK Nuking, DATA LOSS MAY OCCUR.'
  TPOOL.kill
end
watcher(logger) click to toggle source
# File lib/datadog_backup/thread_pool.rb, line 11
def self.watcher(logger)
  Thread.new(TPOOL) do |pool|
    while pool.queue_length.positive?
      sleep 2
      logger.info("#{pool.queue_length} tasks remaining for execution.")
    end
  end
end