[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
parent 092d496944
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.https = self.config["ssl"]
self.server.start(False)
self.server.start(standalone=False)
return True
@export

View File

@ -544,7 +544,7 @@ class DelugeWeb(component.Component):
self.base = self.config["base"]
self.web_api = WebApi()
self.auth = Auth(self.config)
self.standalone = True
# Initalize the plugins
self.plugins = PluginManager()
@ -567,15 +567,31 @@ class DelugeWeb(component.Component):
return 1
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())
self.standalone = standalone
if self.https:
self.start_ssl()
else:
self.start_normal()
component.get("Web").enable()
reactor.run()
if self.standalone:
reactor.run()
def start_normal(self):
self.socket = reactor.listenTCP(self.port, self.site, interface=self.interface)
@ -613,7 +629,8 @@ class DelugeWeb(component.Component):
def shutdown(self, *args):
self.stop()
reactor.stop()
if self.standalone:
reactor.stop()
if __name__ == "__builtin__":