http: Log errors instead of dying for HTTP startup.

This commit is contained in:
Thomas Adamcik 2014-12-20 21:32:08 +01:00
parent b6cf86c6a2
commit 9a2f8a3e4f
2 changed files with 11 additions and 1 deletions

View File

@ -69,6 +69,11 @@ v0.20.0 (UNRELEASED)
make sense for a server such as Mopidy. Currently the only way to find out if make sense for a server such as Mopidy. Currently the only way to find out if
it is in use and will be missed is to go ahead and remove it. it is in use and will be missed is to go ahead and remove it.
**HTTP**
- Log error while starting HTTP apps instead letting the HTTP server thread
die. (Fixes: :issue:`875`)
v0.19.5 (UNRELEASED) v0.19.5 (UNRELEASED)
==================== ====================

View File

@ -129,11 +129,16 @@ class HttpServer(threading.Thread):
def _get_app_request_handlers(self): def _get_app_request_handlers(self):
result = [] result = []
for app in self.apps: for app in self.apps:
try:
request_handlers = app['factory'](self.config, self.core)
except Exception:
logger.exception('Loading %s failed.', app['name'])
continue
result.append(( result.append((
r'/%s' % app['name'], r'/%s' % app['name'],
handlers.AddSlashHandler handlers.AddSlashHandler
)) ))
request_handlers = app['factory'](self.config, self.core)
for handler in request_handlers: for handler in request_handlers:
handler = list(handler) handler = list(handler)
handler[0] = '/%s%s' % (app['name'], handler[0]) handler[0] = '/%s%s' % (app['name'], handler[0])