Sha256: 4a78fc155754e8c76b5b3361844e68c851001e66d22a73fdd1f3ecec011506e6
Contents?: true
Size: 1.01 KB
Versions: 37
Compression:
Stored size: 1.01 KB
Contents
# encoding: utf-8 require "logstash/namespace" require "logstash/logging" class LogStash::ThreadWatchdog attr_accessor :logger attr_accessor :threads class TimeoutError < StandardError; end public def initialize(threads, watchdog_timeout=10) @threads = threads @watchdog_timeout = watchdog_timeout end # def initialize public def watch while sleep(1) cutoff = Time.now - @watchdog_timeout @threads.each do |t| watchdog = t[:watchdog] if watchdog and watchdog <= cutoff age = Time.now - watchdog @logger.fatal("thread watchdog timeout", :thread => t, :backtrace => t.backtrace, :thread_watchdog => watchdog, :age => age, :cutoff => @watchdog_timeout, :state => t[:watchdog_state]) raise TimeoutError, "watchdog timeout" end end end end # def watch end # class LogStash::ThreadWatchdog
Version data entries
37 entries across 37 versions & 4 rubygems