Class: Pushr::Daemon::PidFile

Inherits:
Object
  • Object
show all
Defined in:
lib/pushr/daemon/pid_file.rb

Class Method Summary collapse

Class Method Details

.delete(pid_file) ⇒ Object



16
17
18
# File 'lib/pushr/daemon/pid_file.rb', line 16

def self.delete(pid_file)
  File.delete(pid_file) if !pid_file.blank? && File.exist?(pid_file)
end

.write(pid_file) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/pushr/daemon/pid_file.rb', line 4

def self.write(pid_file)
  unless pid_file.nil?
    begin
      File.open(pid_file, 'w') do |f|
        f.puts Process.pid
      end
    rescue SystemCallError => e
      logger.error("Failed to write PID to '#{pid_file}': #{e.inspect}")
    end
  end
end