Changeset bb0e69
- Timestamp:
- 05/08/2016 11:00:44 AM (9 years ago)
- Branches:
- 2.0.x, develop, master
- Children:
- 616523c
- Parents:
- d5294d
- git-author:
- bendikro <bro.devel+deluge@gmail.com> (04/28/2016 10:13:28 PM)
- git-committer:
- Calum Lind <calumlind+deluge@gmail.com> (05/08/2016 11:00:44 AM)
- Location:
- deluge
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
deluge/plugins/WebUi/deluge/plugins/webui/core.py
rd5294d rbb0e69 67 67 self.server = component.get("DelugeWeb") 68 68 except KeyError: 69 self.server = server.DelugeWeb( )69 self.server = server.DelugeWeb(daemon=False) 70 70 71 71 self.server.port = self.config["port"] 72 72 self.server.https = self.config["ssl"] 73 73 try: 74 self.server.start( standalone=False)74 self.server.start() 75 75 except CannotListenError as ex: 76 76 log.warn("Failed to start WebUI server: %s", ex) -
deluge/tests/test_web_api.py
rd5294d rbb0e69 65 65 self.config = configmanager.ConfigManager("web.conf", config_defaults) 66 66 67 self.deluge_web = DelugeWeb( )67 self.deluge_web = DelugeWeb(daemon=False) 68 68 69 69 host = list(self.deluge_web.web_api.host_list["hosts"][0]) -
deluge/ui/gtkui/gtkui.py
rd5294d rbb0e69 29 29 except ReactorAlreadyInstalledError as ex: 30 30 # Running unit tests so trial already installed a rector 31 pass31 from twisted.internet import reactor 32 32 33 33 import deluge.common … … 152 152 def run(options): 153 153 try: 154 GtkUI(options) 154 gtkui = GtkUI(options) 155 gtkui.start() 155 156 except Exception as ex: 156 157 log.exception(ex) … … 251 252 self.daemon_bps = (0, 0, 0) 252 253 self.rpc_stats = LoopingCall(self.print_rpc_stats) 254 self.closing = False 253 255 254 256 # Twisted catches signals to terminate, so have it call a pre_shutdown method. 255 257 reactor.addSystemEventTrigger("before", "gtkui_close", self.close) 256 257 reactor.callWhenRunning(self._on_reactor_start)258 self.closing = False259 258 260 259 def gtkui_sigint_handler(num, frame): … … 263 262 264 263 signal.signal(signal.SIGINT, gtkui_sigint_handler) 264 265 def start(self): 266 reactor.callWhenRunning(self._on_reactor_start) 265 267 266 268 # Initialize gdk threading -
deluge/ui/gtkui/ipcinterface.py
rd5294d rbb0e69 75 75 def __init__(self, args): 76 76 component.Component.__init__(self, "IPCInterface") 77 self.listener = None 77 78 ipc_dir = get_config_dir("ipc") 78 79 if not os.path.exists(ipc_dir): … … 92 93 import random 93 94 port = random.randrange(20000, 65535) 94 reactor.listenTCP(port, self.factory)95 self.listener = reactor.listenTCP(port, self.factory) 95 96 # Store the port number in the socket file 96 97 open(socket, "w").write(str(port)) … … 133 134 self.factory = Factory() 134 135 self.factory.protocol = IPCProtocolServer 135 reactor.listenUNIX(socket, self.factory, wantPID=True)136 self.listener = reactor.listenUNIX(socket, self.factory, wantPID=True) 136 137 except twisted.internet.error.CannotListenError as ex: 137 138 log.info("Deluge is already running! Sending arguments to running instance...") … … 161 162 import win32api 162 163 win32api.CloseHandle(self.mutex) 164 if self.listener: 165 return self.listener.stopListening() 163 166 164 167 -
deluge/ui/web/server.py
rd5294d rbb0e69 533 533 class DelugeWeb(component.Component): 534 534 535 def __init__(self, options=None): 536 super(DelugeWeb, self).__init__("DelugeWeb") 535 def __init__(self, options=None, daemon=True): 536 """ 537 Setup the DelugeWeb server. 538 539 Args: 540 options (argparse.Namespace): The web server options. 541 daemon (bool): If True run web server as a seperate daemon process (starts a twisted 542 reactor). If False shares the process and twisted reactor from WebUI plugin or tests. 543 544 """ 545 component.Component.__init__(self, "DelugeWeb", depend=["Web"]) 537 546 self.config = configmanager.ConfigManager("web.conf", CONFIG_DEFAULTS) 538 547 self.config.run_converter((0, 1), 2, self._migrate_config_1_to_2) … … 568 577 569 578 self.auth = Auth(self.config) 570 self. standalone = True579 self.daemon = daemon 571 580 # Initalize the plugins 572 581 self.plugins = PluginManager() … … 595 604 SetConsoleCtrlHandler(win_handler) 596 605 597 def start(self , standalone=True):606 def start(self): 598 607 """ 599 608 Start the DelugeWeb server 600 601 When running WebUI plugin, the server must not try to start602 the twisted reactor.603 604 Args:605 standalone (bool): Whether the server runs as a standalone process606 If standalone, start twisted reactor.607 609 """ 608 610 if self.socket: … … 610 612 return 611 613 612 self.standalone = standalone613 614 log.info("Starting webui server at PID %s", os.getpid()) 614 615 if self.https: … … 619 620 component.get("Web").enable() 620 621 621 if self. standalone:622 if self.daemon: 622 623 reactor.run() 623 624 … … 642 643 def stop(self): 643 644 log.info("Shutting down webserver") 644 component.get("Web").disable() 645 try: 646 component.get("Web").disable() 647 except KeyError: 648 pass 645 649 646 650 self.plugins.disable_plugins() … … 658 662 def shutdown(self, *args): 659 663 self.stop() 660 if self. standaloneand reactor.running:664 if self.daemon and reactor.running: 661 665 reactor.stop() 662 666 -
deluge/ui/web/web.py
rd5294d rbb0e69 61 61 self.server.start() 62 62 except CannotListenError as ex: 63 log.error("%s \nCheck that deluge-web or webui plugin arenot already running.", ex)63 log.error("%s \nCheck that deluge-web or webui plugin is not already running.", ex) 64 64 except Exception as ex: 65 65 log.exception(ex)
Note:
See TracChangeset
for help on using the changeset viewer.