class Dasht::Base
Attributes
background[RW]
boards[RW]
default_height[RW]
default_refresh[RW]
default_resolution[RW]
default_width[RW]
history[RW]
metrics[RW]
port[RW]
Settings.
rack_app[RW]
reloader[RW]
Public Class Methods
new()
click to toggle source
# File lib/dasht/base.rb, line 17 def initialize @boards = {} @log_threads = {} @metrics = Metrics.new(self) @reloader = Reloader.new(self) @rack_app = RackApp.new(self) end
Public Instance Methods
board(name = "default") { |board| ... }
click to toggle source
# File lib/dasht/base.rb, line 74 def board(name = "default", &block) name = name.to_s board = @boards[name] = Board.new(self, name) yield(board) if block board end
interval(metric, &block)
click to toggle source
# File lib/dasht/base.rb, line 46 def interval(metric, &block) Thread.new do begin while true value = block.call metrics.set(metric, value, :last, Time.now.to_i) if value end rescue => e log e raise e end end end
log(s)
click to toggle source
# File lib/dasht/base.rb, line 25 def log(s) if s.class < Exception print "\n#{s}\n" print s.backtrace.join("\n") else print "\r#{s}\n" end end
reload(&block)
click to toggle source
# File lib/dasht/base.rb, line 102 def reload(&block) @boards = {} @log_threads.values.map(&:terminate) @log_threads = {} begin block.call(self) rescue => e log e raise e end @log_threads.values.map(&:run) end
run(&block)
click to toggle source
RUN & RELOAD ###
# File lib/dasht/base.rb, line 83 def run(&block) if @already_running begin reload(&block) rescue => e log e end return end @already_running = true @reloader.run block.call(self) @log_threads.values.map(&:run) @rack_app.run(port) end
start(command) { |log_thread| ... }
click to toggle source
DATA INGESTION ###
# File lib/dasht/base.rb, line 36 def start(command, &block) log_thread = @log_threads[command] = LogThread.new(self, command) yield(log_thread) if block log_thread end
system_plugins_path()
click to toggle source
# File lib/dasht/base.rb, line 66 def system_plugins_path File.join(File.dirname(__FILE__), "..", "..", "assets", "plugins") end
tail(path)
click to toggle source
# File lib/dasht/base.rb, line 42 def tail(path) start("tail -F -n 0 \"#{path}\"") end
user_plugins_path()
click to toggle source
# File lib/dasht/base.rb, line 70 def user_plugins_path File.join(File.dirname($PROGRAM_NAME), "plugins") end
views_path()
click to toggle source
DASHBOARD ###
# File lib/dasht/base.rb, line 62 def views_path File.join(File.dirname(__FILE__), "..", "..", "views") end