[WebUI] Fix #2798: WebUI plugin fails to start

This commit is contained in:
bendikro 2016-04-13 21:01:27 +02:00 committed by Calum Lind
commit 64c67a07dd
2 changed files with 22 additions and 5 deletions

View file

@ -71,7 +71,7 @@ class Core(CorePluginBase):
self.server.port = self.config["port"] self.server.port = self.config["port"]
self.server.https = self.config["ssl"] self.server.https = self.config["ssl"]
self.server.start(False) self.server.start(standalone=False)
return True return True
@export @export

View file

@ -544,7 +544,7 @@ class DelugeWeb(component.Component):
self.base = self.config["base"] self.base = self.config["base"]
self.web_api = WebApi() self.web_api = WebApi()
self.auth = Auth(self.config) self.auth = Auth(self.config)
self.standalone = True
# Initalize the plugins # Initalize the plugins
self.plugins = PluginManager() self.plugins = PluginManager()
@ -567,14 +567,30 @@ class DelugeWeb(component.Component):
return 1 return 1
SetConsoleCtrlHandler(win_handler) SetConsoleCtrlHandler(win_handler)
def start(self): def start(self, standalone=True):
"""
Start the DelugeWeb server
When running WebUI plugin, the server must not try to start
the twisted reactor.
Args:
standalone (bool): Whether the server runs as a standalone process
If standalone, start twisted reactor.
Returns:
Deferred
"""
log.info("%s %s.", _("Starting server in PID"), os.getpid()) log.info("%s %s.", _("Starting server in PID"), os.getpid())
self.standalone = standalone
if self.https: if self.https:
self.start_ssl() self.start_ssl()
else: else:
self.start_normal() self.start_normal()
component.get("Web").enable() component.get("Web").enable()
if self.standalone:
reactor.run() reactor.run()
def start_normal(self): def start_normal(self):
@ -613,6 +629,7 @@ class DelugeWeb(component.Component):
def shutdown(self, *args): def shutdown(self, *args):
self.stop() self.stop()
if self.standalone:
reactor.stop() reactor.stop()