Commit 0f2e3628 authored by Vincent Pelletier's avatar Vincent Pelletier

Remove the need to resolve hostname to determine node identifier when http...

Remove the need to resolve hostname to determine node identifier when http server explicitely listens on a non-wilcard address.
Also, fix timerserver startup when http server listens on a non-wilcard address.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@28957 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9e3f07f1
......@@ -692,16 +692,17 @@ class ActivityTool (Folder, UniqueObject):
""" Return current node in form ip:port """
global currentNode
if currentNode is None:
port = ''
ip = port = ''
from asyncore import socket_map
for k, v in socket_map.items():
if hasattr(v, 'port'):
if hasattr(v, 'addr'):
# see Zope/lib/python/App/ApplicationManager.py: def getServers(self)
type = str(getattr(v, '__class__', 'unknown'))
if type == 'ZServer.HTTPServer.zhttp_server':
port = v.port
ip, port = v.addr
break
ip = socket.gethostbyname(socket.gethostname())
if ip == '0.0.0.0':
ip = socket.gethostbyname(socket.gethostname())
currentNode = '%s:%s' %(ip, port)
return currentNode
......
......@@ -226,16 +226,17 @@ class AlarmTool(BaseTool):
""" Return current node in form ip:port """
global current_node
if current_node is None:
port = ''
ip = port = ''
from asyncore import socket_map
for k, v in socket_map.items():
if hasattr(v, 'port'):
if hasattr(v, 'addr'):
# see Zope/lib/python/App/ApplicationManager.py: def getServers(self)
type = str(getattr(v, '__class__', 'unknown'))
if type == 'ZServer.HTTPServer.zhttp_server':
port = v.port
ip, port = v.addr
break
ip = socket.gethostbyname(socket.gethostname())
if ip == '0.0.0.0':
ip = socket.gethostbyname(socket.gethostname())
current_node = '%s:%s' %(ip, port)
return current_node
......
......@@ -40,19 +40,21 @@ class TimerServer:
# wait until the zhttp_server exist in socket_map
# because TimerService has to be started after the Zope HTTPServer
from asyncore import socket_map
ip = port = ''
while 1:
time.sleep(5)
for k, v in socket_map.items():
if hasattr(v, 'port'):
if hasattr(v, 'addr'):
# see Zope/lib/python/App/ApplicationManager.py: def getServers(self)
type = str(getattr(v, '__class__', 'unknown'))
if type == 'ZServer.HTTPServer.zhttp_server':
port = v.port
ip, port = v.addr
break
if port:
break
ip = socket.gethostbyname(socket.gethostname())
if ip == '0.0.0.0':
ip = socket.gethostbyname(socket.gethostname())
# To be very sure, try to connect to the HTTPServer
# and only start after we are able to connect and got a response
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment