Skip to content

Commit 2933bc8

Browse files
committed
fix
1 parent ef7e720 commit 2933bc8

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

docker/entrypoint.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,42 @@ def launch_pycsw(pycsw_config, workers=2, reload=False):
8080
except Exception as err:
8181
LOGGER.debug(err)
8282

83-
repo = Repository(database, StaticContext())
83+
if 'source' in pycsw_config['repository']: # load custom repository
84+
rs = pycsw_config['repository']['source']
85+
rs_modname, rs_clsname = rs.rsplit('.', 1)
86+
87+
rs_mod = __import__(rs_modname, globals(), locals(), [rs_clsname])
88+
rs_cls = getattr(rs_mod, rs_clsname)
89+
90+
try:
91+
connection_done = False
92+
max_attempts = 0
93+
max_retries = pycsw_config['repository'].get('maxretries', 5)
94+
while not connection_done and max_attempts <= max_retries:
95+
try:
96+
repo = rs_cls(pycsw_config['repository'], StaticContext())
97+
LOGGER.debug('Custom repository %s loaded' % pycsw_config['repository']['source'])
98+
connection_done = True
99+
except Exception as err:
100+
LOGGER.debug(f'Repository not loaded retry connection {max_attempts}: {err}')
101+
max_attempts += 1
102+
except Exception as err:
103+
msg = 'Could not load custom repository %s: %s' % (rs, err)
104+
LOGGER.exception(msg)
105+
error = 1
106+
code = 'NoApplicableCode'
107+
locator = 'service'
108+
text = 'Could not initialize repository. Check server logs'
109+
110+
else:
111+
try:
112+
LOGGER.info('Loading default repository')
113+
repo = repository.Repository(pycsw_config, StaticContext())
114+
LOGGER.debug(f'Repository loaded {repo.dbtype}')
115+
except Exception as err:
116+
msg = f'Could not load repository {err}'
117+
LOGGER.exception(msg)
118+
raise
84119

85120
repo.ping()
86121

pycsw/plugins/repository/solr_metno.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,9 @@ def _doc2record(self, doc: dict):
528528

529529
return self.dataset(record)
530530

531+
def ping(self):
532+
pass
533+
531534

532535
def keywords2themes(doc: dict) -> list:
533536
schemes = {}

0 commit comments

Comments
 (0)