Class: Puppet::Util::Pidlock Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/util/pidlock.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(lockfile) ⇒ Pidlock

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Pidlock.



7
8
9
# File 'lib/puppet/util/pidlock.rb', line 7

def initialize(lockfile)
  @lockfile = Puppet::Util::Lockfile.new(lockfile)
end

Instance Method Details

#file_pathObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



43
44
45
# File 'lib/puppet/util/pidlock.rb', line 43

def file_path
  @lockfile.file_path
end

#lockObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



20
21
22
23
24
# File 'lib/puppet/util/pidlock.rb', line 20

def lock
  return mine? if locked?

  @lockfile.lock(Process.pid)
end

#lock_pidObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



34
35
36
37
38
39
40
41
# File 'lib/puppet/util/pidlock.rb', line 34

def lock_pid
  pid = @lockfile.lock_data
  begin
    Integer(pid)
  rescue ArgumentError, TypeError
    nil
  end
end

#locked?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


11
12
13
14
# File 'lib/puppet/util/pidlock.rb', line 11

def locked?
  clear_if_stale
  @lockfile.locked?
end

#mine?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


16
17
18
# File 'lib/puppet/util/pidlock.rb', line 16

def mine?
  Process.pid == lock_pid
end

#unlockObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



26
27
28
29
30
31
32
# File 'lib/puppet/util/pidlock.rb', line 26

def unlock
  if mine?
    return @lockfile.unlock
  else
    false
  end
end