Shut down UiServer if FileServer startup failed

This commit is contained in:
shortcutme 2019-09-19 16:33:45 +02:00
parent 93e6ec4933
commit d7db631b95
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
2 changed files with 21 additions and 1 deletions

View file

@ -2,6 +2,7 @@ import logging
import time
import random
import socket
import sys
import gevent
import gevent.pool
@ -346,7 +347,20 @@ class FileServer(ConnectionServer):
# Bind and start serving sites
def start(self, check_sites=True):
if self.stopping:
return False
ConnectionServer.start(self)
try:
self.stream_server.start()
except Exception as err:
self.log.error("Error listening on: %s:%s: %s" % (self.ip, self.port, err))
if "ui_server" in dir(sys.modules["main"]):
self.log.debug("Stopping UI Server.")
sys.modules["main"].ui_server.stop()
return False
self.sites = self.site_manager.list()
if config.debug:
# Auto reload FileRequest on change