Commit cf3de7f9 authored by Aurelien Campeas's avatar Aurelien Campeas

[hooks] do not crash on startup if the config entry is missing

parent 395866a00f8f
...@@ -23,12 +23,13 @@ class ServerStartupHook(hook.Hook): ...@@ -23,12 +23,13 @@ class ServerStartupHook(hook.Hook):
self.debug('registering kerberos authentifier') self.debug('registering kerberos authentifier')
self.repo.system_source.add_authentifier(XRemoteUserAuthentifier()) self.repo.system_source.add_authentifier(XRemoteUserAuthentifier())
CONFENTRY = 'secret-key-filepath'
def registration_callback(vreg): def registration_callback(vreg):
vreg.register(ServerStartupHook) fpath = vreg.config.get(CONFENTRY)
fpath = vreg.config.get('secret-key-filepath')
if fpath is None or not osp.exists(fpath): if fpath is None or not osp.exists(fpath):
msg = 'invalid or missing value for the secret-key-filepth' msg = 'invalid or missing value for the %s' % CONFENTRY
vreg.error(msg) vreg.error(msg)
raise Exception(msg) else:
vreg.register(ServerStartupHook)
vreg.config._secret = open(fpath, 'rb').read().strip() vreg.config._secret = open(fpath, 'rb').read().strip()
vreg.debug('loaded secret key') vreg.debug('loaded secret key')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment