module MiGA::Common::WithDaemonClass

Helper module with specific class-level functions to be used with +include MiGA::Common::WithDaemon+.

Public Instance Methods

alive_file(path) click to toggle source

Path to the alive file

# File lib/miga/common/with_daemon_class.rb, line 13
def alive_file(path)
  File.join(daemon_home(path), '.daemon-alive')
end
daemon_home(path) click to toggle source

Path to the daemon home from the parent's path

# File lib/miga/common/with_daemon_class.rb, line 7
def daemon_home(path)
  path
end
last_alive(path) click to toggle source

When was a daemon last seen at path?

# File lib/miga/common/with_daemon_class.rb, line 25
def last_alive(path)
  f = alive_file(path)
  f = terminated_file(path) unless File.exist? f
  c = File.read(f)
  return nil if c.nil? || c.empty?

  Time.parse(c)
rescue Errno::ENOENT, ArgumentError
  return nil
end
terminated_file(path) click to toggle source

Path to the terminated file

# File lib/miga/common/with_daemon_class.rb, line 19
def terminated_file(path)
  File.join(daemon_home(path), '.daemon-terminated')
end