Module: Nephos::Bin::Daemon
- Defined in:
- lib/nephos-server/bin-helpers.rb
Class Method Summary collapse
Class Method Details
.detach! ⇒ Object
42 43 44 45 |
# File 'lib/nephos-server/bin-helpers.rb', line 42 def self.detach! Process::daemon(true, false) File.write(get_pid_file, Process::pid.to_s) end |
.get_pid ⇒ Object
51 52 53 54 55 56 |
# File 'lib/nephos-server/bin-helpers.rb', line 51 def self.get_pid return nil if not File.exist?(get_pid_file) v = File.read(get_pid_file) v = Integer(v) rescue nil return v end |
.get_pid_file ⇒ Object
47 48 49 |
# File 'lib/nephos-server/bin-helpers.rb', line 47 def self.get_pid_file return ".pid" end |
.kill! ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/nephos-server/bin-helpers.rb', line 28 def self.kill! d = get_pid return false unless d begin Process::kill(2, d) rescue => err raise "Cannot kill #{d} ! (#{err.})" if $debug raise "Cannot kill #{d} !" ensure File.delete(get_pid_file) end return true end |
.started? ⇒ Boolean
24 25 26 |
# File 'lib/nephos-server/bin-helpers.rb', line 24 def self.started? get_pid != nil end |