core: Log around process locks
This commit is contained in:
parent
4372ab034e
commit
d96c5a81af
|
@ -360,15 +360,19 @@ module Vagrant
|
||||||
# The path to this lock
|
# The path to this lock
|
||||||
lock_path = data_dir.join("lock.#{name}.lock")
|
lock_path = data_dir.join("lock.#{name}.lock")
|
||||||
|
|
||||||
|
@logger.debug("Attempting to acquire process-lock: #{name}")
|
||||||
File.open(lock_path, "w+") do |f|
|
File.open(lock_path, "w+") do |f|
|
||||||
# The file locking fails only if it returns "false." If it
|
# The file locking fails only if it returns "false." If it
|
||||||
# succeeds it returns a 0, so we must explicitly check for
|
# succeeds it returns a 0, so we must explicitly check for
|
||||||
# the proper error case.
|
# the proper error case.
|
||||||
if f.flock(File::LOCK_EX | File::LOCK_NB) === false
|
if f.flock(File::LOCK_EX | File::LOCK_NB) === false
|
||||||
|
@logger.warn("Process-lock in use: #{name}")
|
||||||
raise Errors::EnvironmentLockedError,
|
raise Errors::EnvironmentLockedError,
|
||||||
name: name
|
name: name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@logger.info("Acquired process lock: #{name}")
|
||||||
|
|
||||||
begin
|
begin
|
||||||
# Mark that we have a lock
|
# Mark that we have a lock
|
||||||
@locks[name] = true
|
@locks[name] = true
|
||||||
|
|
Loading…
Reference in New Issue