Method: Eye::Process::System#compare_identity

Defined in:
lib/eye/process/system.rb

#compare_identity(pid = self.pid) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/eye/process/system.rb', line 39

def compare_identity(pid = self.pid)
  return :ok unless self[:check_identity]
  return :no_pid unless pid
  id = get_identity
  return :no_pid_file unless id
  st = Eye::SystemResources.start_time(pid)
  return :no_start_time unless st
  st1 = st.to_i
  id1 = id.to_i
  if (id1 - st1).abs > self[:check_identity_grace]
    args = Eye::SystemResources.args(pid)
    msg = "pid_file: '#{Eye::Utils.human_time2(id)}', process: '#{Eye::Utils.human_time2(st)}' (#{args})"
    res = id1 < st1 ? :fail : :touched
    warn "compare_identity: #{res}, #{msg}"
    res
  else
    :ok
  end
end