Update error handling for lock_client
This commit is contained in:
parent
4fb6a49b33
commit
877b1c440e
|
@ -42,26 +42,30 @@ def run_configuration(config_filename, config, arguments):
|
||||||
* JSON output strings from successfully executing any actions that produce JSON
|
* JSON output strings from successfully executing any actions that produce JSON
|
||||||
* logging.LogRecord instances containing errors from any actions or backup hooks that fail
|
* logging.LogRecord instances containing errors from any actions or backup hooks that fail
|
||||||
'''
|
'''
|
||||||
|
|
||||||
(location, storage, retention, consistency, hooks) = (
|
(location, storage, retention, consistency, hooks) = (
|
||||||
config.get(section_name, {})
|
config.get(section_name, {})
|
||||||
for section_name in ('location', 'storage', 'retention', 'consistency', 'hooks')
|
for section_name in ('location', 'storage', 'retention', 'consistency', 'hooks')
|
||||||
)
|
)
|
||||||
global_arguments = arguments['global']
|
global_arguments = arguments['global']
|
||||||
|
|
||||||
if location.get("lock_client",False):
|
|
||||||
lock_f = open(config_filename)
|
|
||||||
try:
|
|
||||||
fcntl.flock(lock_f.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
|
|
||||||
except IOError:
|
|
||||||
logger.critical("Failed to acquire lock for {}".format(config_filename))
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
local_path = location.get('local_path', 'borg')
|
local_path = location.get('local_path', 'borg')
|
||||||
remote_path = location.get('remote_path')
|
remote_path = location.get('remote_path')
|
||||||
borg_environment.initialize(storage)
|
borg_environment.initialize(storage)
|
||||||
encountered_error = None
|
encountered_error = None
|
||||||
error_repository = ''
|
error_repository = ''
|
||||||
|
|
||||||
|
if location.get("lock_client",False):
|
||||||
|
lock_f = open(config_filename)
|
||||||
|
try:
|
||||||
|
fcntl.flock(lock_f.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||||
|
except IOError as error:
|
||||||
|
encountered_error = error
|
||||||
|
yield from make_error_log_records(
|
||||||
|
'{}: Failed to acquire lock'.format(config_filename), error
|
||||||
|
)
|
||||||
|
|
||||||
|
if not encountered_error:
|
||||||
if 'create' in arguments:
|
if 'create' in arguments:
|
||||||
try:
|
try:
|
||||||
dispatch.call_hooks(
|
dispatch.call_hooks(
|
||||||
|
|
Loading…
Reference in New Issue