class Memosig::App
Attributes
config[R]
Public Class Methods
new(config: nil)
click to toggle source
# File lib/memosig/app.rb, line 9 def initialize(config: nil) @config = ComplexConfig::Provider.config(config) end
Public Instance Methods
run()
click to toggle source
# File lib/memosig/app.rb, line 15 def run check_memory sleep (@config.wait_period? || 300) end
Private Instance Methods
check_memory()
click to toggle source
# File lib/memosig/app.rb, line 38 def check_memory output "checking memory limits" processes = current_processes for (pattern, config) in @config.processes check_memory_for pattern, config, processes end end
check_memory_for(pattern, config, processes)
click to toggle source
# File lib/memosig/app.rb, line 26 def check_memory_for(pattern, config, processes) processes.inject(false) do |matched, process| m = new_matcher(pattern, config).match?(process) matched || m end and return error "pattern #{pattern.to_s.inspect} didn't match any processes" end
current_processes()
click to toggle source
# File lib/memosig/app.rb, line 34 def current_processes Memosig::ProcStat.all end
new_matcher(pattern, config)
click to toggle source
# File lib/memosig/app.rb, line 22 def new_matcher(pattern, config) Memosig::Matcher.new(pattern, config) end