Class: Amqpop::LockFile

Inherits:
Object
  • Object
show all
Defined in:
lib/amqpop/lock_file.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ LockFile

Returns a new instance of LockFile.



6
7
8
# File 'lib/amqpop/lock_file.rb', line 6

def initialize(options)
	@options = options.dup
end

Instance Method Details

#acquire!Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/amqpop/lock_file.rb', line 10

def acquire!
  if exist?
    pid = File.read(file_path).strip
    if pid_alive?(pid)
      acquire_failed(pid)
      return false
    else
      clean_file
    end
  end
  create_lock
  return true
end

#release!Object



24
25
26
# File 'lib/amqpop/lock_file.rb', line 24

def release!
  clean_file
end