forked from shaba/openuds
More fixes (in fact, fixing fixes... :P) for actors
This commit is contained in:
parent
1f6279cd46
commit
5af198db75
@ -198,11 +198,15 @@ class HTTPServerThread(threading.Thread):
|
||||
|
||||
|
||||
def initiateServer(self, address):
|
||||
self.server = socketserver.TCPServer(address, HTTPServerHandler)
|
||||
self.address = (address[0], address[1]) # Copy address & keep it for future reference...
|
||||
|
||||
addr = ('0.0.0.0', address[1]) # Adapt to listen on 0.0.0.0
|
||||
|
||||
self.server = socketserver.TCPServer(addr, HTTPServerHandler)
|
||||
self.server.socket = ssl.wrap_socket(self.server.socket, certfile=self.certFile, server_side=True)
|
||||
|
||||
def getServerUrl(self):
|
||||
return 'https://{}:{}/{}'.format(self.server.server_address[0], self.server.server_address[1], HTTPServerHandler.uuid)
|
||||
return 'https://{}:{}/{}'.format(self.address[0], self.address[1], HTTPServerHandler.uuid)
|
||||
|
||||
def stop(self):
|
||||
logger.debug('Stopping REST Service')
|
||||
@ -211,11 +215,14 @@ class HTTPServerThread(threading.Thread):
|
||||
def restart(self, address=None):
|
||||
|
||||
if address is None:
|
||||
address = self.server.server_address
|
||||
# address = self.server.server_address
|
||||
address = self.address
|
||||
|
||||
self.stop()
|
||||
self.address = (address[0], address[1]) # Copy address & keep it for future reference
|
||||
|
||||
self.initiateServer(address)
|
||||
# Listening on 0.0.0.0, does not need to restart listener..
|
||||
# self.stop()
|
||||
# self.initiateServer(address)
|
||||
|
||||
def run(self):
|
||||
self.server.serve_forever()
|
||||
|
@ -210,9 +210,9 @@ class CommonService(object):
|
||||
self.knownIps = dict(((v.mac, v.ip) for v in netInfo))
|
||||
|
||||
# And notify new listening address to broker
|
||||
# address = (self.knownIps[self.api.mac], random.randrange(43900, 44000))
|
||||
address = (self.knownIps[self.api.mac], random.randrange(43900, 44000))
|
||||
# And new listening address
|
||||
# self.httpServer.restart(address)
|
||||
self.httpServer.restart(address)
|
||||
# sends notification
|
||||
self.api.notifyComm(self.httpServer.getServerUrl())
|
||||
|
||||
@ -252,8 +252,7 @@ class CommonService(object):
|
||||
self.ipc.start()
|
||||
|
||||
if self.api.mac in self.knownIps:
|
||||
# address = (self.knownIps[self.api.mac], random.randrange(43900, 44000))
|
||||
address = ('0.0.0.0', random.randrange(43900, 44000))
|
||||
address = (self.knownIps[self.api.mac], random.randrange(43900, 44000))
|
||||
logger.info('Starting REST listener at {}'.format(address))
|
||||
self.httpServer = httpserver.HTTPServerThread(address, self)
|
||||
self.httpServer.start()
|
||||
|
Loading…
Reference in New Issue
Block a user