Class: ProcessSanity::Processes

Inherits:
Object
  • Object
show all
Defined in:
lib/process_sanity.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#desktop_notificationsObject

Returns the value of attribute desktop_notifications.



5
6
7
# File 'lib/process_sanity.rb', line 5

def desktop_notifications
  @desktop_notifications
end

#is_aggressiveObject

Returns the value of attribute is_aggressive.



5
6
7
# File 'lib/process_sanity.rb', line 5

def is_aggressive
  @is_aggressive
end

#namesObject

Returns the value of attribute names.



5
6
7
# File 'lib/process_sanity.rb', line 5

def names
  @names
end

#skip_runObject

Returns the value of attribute skip_run.



5
6
7
# File 'lib/process_sanity.rb', line 5

def skip_run
  @skip_run
end

Instance Method Details

#check_processesObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 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("red")
      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