Sha256: 976f5794595afdbfa3c10e0299389e73811e8b4b4ac549bc73edacd711fcb114
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
module Kryten::Runner attr_accessor :timer attr_reader :running, :started def initialize title=nil @name, @running, @started = title, false, false end def setup log "setting up" Signal.trap("INT", proc { stop_running }) Signal.trap("TERM", proc { stop_running }) end def start setup log "started" @started = true while started do sleep timer @running = true run @running = false end log "stopped" true rescue => e log :error, "error: #{e} - from: #{e.backtrace.first}" raise end def timer @timer || 4 end # stop the loop def stop_running @started = false shutdown end def debug log "debugging" setup 2.times do run sleep timer end end def log message puts [name, message].join(': ') end def name @name || self.class.to_s.gsub('::','-').downcase end def status log [started ? 'on and ' : 'off and ', running ? 'running' : 'sleeping'].join started end # hook methods def shutdown; nil; end def run; nil; end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kryten-0.3.0 | lib/kryten/runner.rb |