class ProcessSanity::Processes

Attributes

desktop_notifications[RW]
is_aggressive[RW]
names[RW]
skip_run[RW]

Public Instance Methods

check_processes() click to toggle source
# File lib/process_sanity.rb, line 7
def check_processes
  errors = []
  names.each do |process_name|
    id = system("pgrep -f #{process_name} > /dev/null 2>&1")
    unless id
      puts "Process-Sanity: #{process_name} IS A DEPENDENCY YET IT IS NOT RUNNING!".colorize(:green)
      errors.push(process_name)
    end
  end
  if errors.any?
    if desktop_notifications
      system("terminal-notifier -title 'Process-Sanity' -message 'You forgot to run some processes, Check your Rails Logs!'" )
    end
    raise "Process-Sanity:: YOU HAVE FORGOT TO PRE-RUN SOME PROCESSES: #{process_names.inspect}"  if is_aggressive
  end

end