module ConfigmonkeyCli::Application::Core
Public Instance Methods
fire(which, *args)
click to toggle source
# File lib/configmonkey_cli/application/core.rb, line 54 def fire which, *args return if @disable_event_firing sync { debug "[Event] Firing #{which} (#{@hooks[which].try(:length) || 0} handlers) #{args.map(&:class)}", 99 } @hooks[which] && @hooks[which].each{|h| h.call(*args) } end
haltpoint(thr = Thread.current)
click to toggle source
# File lib/configmonkey_cli/application/core.rb, line 27 def haltpoint thr = Thread.current thr.raise Interrupt if $cm_runtime_exiting end
hook(*which, &hook_block)
click to toggle source
interruptable(&block)
click to toggle source
# File lib/configmonkey_cli/application/core.rb, line 31 def interruptable &block Thread.new do begin thr = Thread.current $interruptable_threads << Thread.current thr[:return_value] = block.call(thr) ensure $interruptable_threads.delete(Thread.current) end end.join[:return_value] end
logger()
click to toggle source
# File lib/configmonkey_cli/application/core.rb, line 68 def logger sync do @logger ||= begin FileUtils.mkdir_p(File.dirname(@opts[:logfile])) Logger.new(@opts[:logfile], 10, 1024000) end end end
logger_filename()
click to toggle source
release_signals()
click to toggle source
# File lib/configmonkey_cli/application/core.rb, line 21 def release_signals debug "Releasing INT signal..." Signal.trap("INT", "DEFAULT") # Signal.trap("TERM", "DEFAULT") end
trap_signals()
click to toggle source
¶ ↑
Signal trapping =¶ ↑
¶ ↑
# File lib/configmonkey_cli/application/core.rb, line 7 def trap_signals debug "Trapping INT signal..." $interruptable_threads = [] Signal.trap("INT") do $cm_runtime_exiting = true $interruptable_threads.each{|thr| thr.raise(Interrupt) if thr.alive? } Kernel.puts "Interrupting..." end # Signal.trap("TERM") do # $cm_runtime_exiting = true # Kernel.puts "Terminating..." # end end