updated service loading to catch on_load exceptions and ignore service
This commit is contained in:
parent
1248982d8c
commit
d6cf09e4b8
1 changed files with 8 additions and 1 deletions
|
@ -249,6 +249,7 @@ class ServiceManager(object):
|
|||
|
||||
:param CoreService service: service to add
|
||||
:return: nothing
|
||||
:raises ValueError: when service cannot be loaded
|
||||
"""
|
||||
name = service.name
|
||||
logging.debug("loading service: class(%s) name(%s)", service.__name__, name)
|
||||
|
@ -261,6 +262,13 @@ class ServiceManager(object):
|
|||
for executable in service.executables:
|
||||
which(executable, required=True)
|
||||
|
||||
# validate service on load succeeds
|
||||
try:
|
||||
service.on_load()
|
||||
except Exception as e:
|
||||
logging.exception("error during service(%s) on load", service.name)
|
||||
raise ValueError(e)
|
||||
|
||||
# make service available
|
||||
cls.services[name] = service
|
||||
|
||||
|
@ -289,7 +297,6 @@ class ServiceManager(object):
|
|||
for service in services:
|
||||
if not service.name:
|
||||
continue
|
||||
service.on_load()
|
||||
|
||||
try:
|
||||
cls.add(service)
|
||||
|
|
Loading…
Add table
Reference in a new issue