Class: Daemons::Reporter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Reporter

Returns a new instance of Reporter.


5
6
7
8
9
10
11
# File 'lib/daemons/reporter.rb', line 5

def initialize(options)
  @options = options

  if !options[:shush]
    $stdout.sync = true
  end
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options


3
4
5
# File 'lib/daemons/reporter.rb', line 3

def options
  @options
end

Instance Method Details

#backtrace_not_supportedObject


31
32
33
# File 'lib/daemons/reporter.rb', line 31

def backtrace_not_supported 
  output_message 'option :backtrace is not supported with :mode => :exec, ignoring'
end

#cannot_stop_process(app_name, pid) ⇒ Object


40
41
42
43
# File 'lib/daemons/reporter.rb', line 40

def cannot_stop_process(app_name, pid)
  output_message "#{app_name}: unable to forcefully kill process with pid #{pid}."
  $stdout.flush
end

#changing_process_privilege(user, group = user) ⇒ Object


19
20
21
# File 'lib/daemons/reporter.rb', line 19

def changing_process_privilege(user, group = user)
  output_message "Changing process privilege to #{user}:#{group}"
end

#deleted_found_pidfile(pid, f) ⇒ Object


23
24
25
# File 'lib/daemons/reporter.rb', line 23

def deleted_found_pidfile(pid, f)
  output_message "pid-file for killed process #{pid} found (#{f}), deleting."
end

#output_message(message) ⇒ Object


13
14
15
16
17
# File 'lib/daemons/reporter.rb', line 13

def output_message(message)
  if !options[:shush]
    puts message
  end
end

#process_started(app_name, pid) ⇒ Object


27
28
29
# File 'lib/daemons/reporter.rb', line 27

def process_started(app_name, pid)
  output_message  "#{app_name}: process with pid #{pid} started."
end

#status(app_name, running, pid_exists, pid) ⇒ Object


50
51
52
# File 'lib/daemons/reporter.rb', line 50

def status(app_name, running, pid_exists, pid)
  output_message "#{app_name}: #{running ? '' : 'not '}running#{(running and pid_exists) ? ' [pid ' + pid.to_s + ']' : ''}#{(pid_exists and not running) ? ' (but pid-file exists: ' + pid.to_s + ')' : ''}"
end

#stopped_process(app_name, pid) ⇒ Object


45
46
47
48
# File 'lib/daemons/reporter.rb', line 45

def stopped_process(app_name, pid)
  output_message "#{app_name}: process with pid #{pid} successfully stopped."
  $stdout.flush
end

#stopping_process(app_name, pid, sig, wait) ⇒ Object


35
36
37
38
# File 'lib/daemons/reporter.rb', line 35

def stopping_process(app_name, pid, sig, wait)
  output_message "#{app_name}: trying to stop process with pid #{pid}#{' forcefully :(' if sig == 'KILL'} sending #{sig} and waiting #{wait}s ..."
  $stdout.flush
end