Class: Daemon::Cluster::PidFile

Inherits:
Object
  • Object
show all
Defined in:
lib/serverside/cluster.rb

Overview

Stores and recalls pids for the child processes.

Constant Summary collapse

FN =
'serverside_cluster.pid'

Class Method Summary collapse

Class Method Details

.deleteObject

Deletes the cluster’s pid file.



12
13
14
# File 'lib/serverside/cluster.rb', line 12

def self.delete
  FileUtils.rm(FN) if File.file?(FN)
end

.recall_pidsObject

Recalls all child pids.



22
23
24
25
26
27
28
29
30
# File 'lib/serverside/cluster.rb', line 22

def self.recall_pids
  pids = []
  File.open(FN, 'r') do |f|
    while !f.eof?
      pids << f.gets.to_i
    end
  end
  pids
end

.store_pid(pid) ⇒ Object

Stores a pid in the cluster’s pid file.



17
18
19
# File 'lib/serverside/cluster.rb', line 17

def self.store_pid(pid)
  File.open(FN, 'a') {|f| f.puts pid}
end