Sha256: 9b5c7e780aeea442a9cd75cc8445aeeb5bb00cdfdbb8270c4418197766332aea
Contents?: true
Size: 936 Bytes
Versions: 32
Compression:
Stored size: 936 Bytes
Contents
class Pigeon::Pidfile # == Constants ============================================================ # == Properties =========================================================== attr_reader :path # == Class Methods ======================================================== # == Instance Methods ===================================================== def initialize(path) @path = path @path += '.pid' unless (@path.match(/\./)) end def running? !!self.running end def running pid = self.saved_pid (pid and Process.kill(0, pid)) ? pid : nil rescue Errno::ESRCH nil end def saved_pid File.read(@path).to_i rescue Errno::ENOENT nil end def create!(pid = nil) open(@path, 'w') do |fh| fh.puts(pid || $$) end end def remove! return unless (exist?) File.unlink(@path) end def exist? File.exist?(@path) end end
Version data entries
32 entries across 32 versions & 1 rubygems