Skip to content

Commit 1cb37f9

Browse files
author
Tomas Pospisek
committed
allow service config file to be optional
Part of qwc-services/qwc-ldap-auth#16 (comment)
1 parent 4b5a9ef commit 1cb37f9

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

qwc_services_core/runtime_config.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ def config_file_path(service, tenant):
1919
filename = '%sConfig.json' % service
2020
return safe_join(config_path, tenant, filename)
2121

22-
def __init__(self, service, logger):
22+
def __init__(self, service, logger, config_file_is_optional = true):
2323
self.service = service
2424
self.logger = logger
2525
self.config = None
26+
self.config_file_is_optional = config_file_is_optional
2627

2728
def set_config(self, config):
2829
""" Directly sets the internal config object. """
@@ -47,10 +48,16 @@ def read_config(self, tenant):
4748
dataout = ENVVAR_PATTERN.sub(envrepl, data)
4849
self.config = json.loads(dataout)
4950
except Exception as e:
50-
self.logger.error(
51-
"Could not load runtime config '%s':\n%s" %
52-
(runtime_config_path, e)
53-
)
51+
if self.config_file_is_optional:
52+
self.logger.info(
53+
"Could not load runtime config '%s':\n%s\nHowever ignoring due to option config_file_is_optional being set to true" %
54+
(runtime_config_path, e)
55+
)
56+
else:
57+
self.logger.error(
58+
"Could not load runtime config '%s':\n%s" %
59+
(runtime_config_path, e)
60+
)
5461
self.config = {}
5562
return self
5663

0 commit comments

Comments
 (0)