Module: MiGA::Common::WithDaemonClass
Overview
Helper module with specific class-level functions to be used with include MiGA::Common::WithDaemon.
Instance Method Summary collapse
-
#alive_file(path) ⇒ Object
Path to the alive file.
-
#daemon_home(path) ⇒ Object
Path to the daemon home from the parent’s
path
. -
#last_alive(path) ⇒ Object
When was a daemon last seen at
path
?. -
#terminated_file(path) ⇒ Object
Path to the terminated file.
Instance Method Details
#alive_file(path) ⇒ Object
Path to the alive file
13 14 15 |
# 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) ⇒ Object
Path to the daemon home from the parent’s path
7 8 9 |
# File 'lib/miga/common/with_daemon_class.rb', line 7 def daemon_home(path) path end |
#last_alive(path) ⇒ Object
When was a daemon last seen at path
?
25 26 27 28 29 30 31 32 33 34 |
# 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) ⇒ Object
Path to the terminated file
19 20 21 |
# File 'lib/miga/common/with_daemon_class.rb', line 19 def terminated_file(path) File.join(daemon_home(path), '.daemon-terminated') end |