Move ConnectionServer listen to separate function to allow TorManager start before connections

This commit is contained in:
shortcutme 2018-04-29 02:44:46 +02:00
parent 40f0ea95ce
commit 3f6b8def05
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
2 changed files with 10 additions and 3 deletions

View file

@ -78,9 +78,14 @@ class ConnectionServer(object):
self.stream_server = StreamServer(
(self.ip, self.port), self.handleIncomingConnection, spawn=self.pool, backlog=100
)
self.stream_server.serve_forever() # Start normal connection server
except Exception, err:
self.log.info("StreamServer bind error, must be running already: %s" % err)
self.log.info("StreamServer bind error: %s" % err)
def listen(self):
try:
self.stream_server.serve_forever()
except Exception, err:
self.log.info("StreamServer listen error: %s" % err)
def stop(self):
self.running = False

View file

@ -379,6 +379,8 @@ class FileServer(ConnectionServer):
from Debug import DebugReloader
DebugReloader(self.reload)
ConnectionServer.start(self)
if check_sites: # Open port, Update sites, Check files integrity
gevent.spawn(self.checkSites)
@ -386,7 +388,7 @@ class FileServer(ConnectionServer):
thread_cleanup_sites = gevent.spawn(self.cleanupSites)
thread_wakeup_watcher = gevent.spawn(self.wakeupWatcher)
ConnectionServer.start(self)
ConnectionServer.listen(self)
self.log.debug("Stopped.")