module MultiDaemons::PidStore

Public Class Methods

cleanup(file_names) click to toggle source
# File lib/multi_daemons/pid_store.rb, line 19
def self.cleanup(file_names)
  file_names = [file_names].flatten
  file_names.each do |file_name|
    next unless File.exist?(file_name)

    FileUtils.rm(file_name)
  end
end
get(file_name) click to toggle source
# File lib/multi_daemons/pid_store.rb, line 7
def self.get(file_name)
  [].tap do |pids|
    unless File.exist?(file_name)
      pids << nil
      next
    end
    File.read(file_name).each_line do |line|
      pids << line.to_i
    end
  end
end
store(file_name, pid) click to toggle source
# File lib/multi_daemons/pid_store.rb, line 3
def self.store(file_name, pid)
  File.open(file_name, 'a') { |f| f << "#{pid}\n" }
end