plone / plone.recipe.zope2instance

zc.buildout recipe to setup and configure a Zope 2 instance.
https://pypi.org/project/plone.recipe.zope2instance
6 stars 23 forks source link

http-address does not support multiple ports as value #148

Closed ale-rt closed 4 years ago

ale-rt commented 4 years ago

Given that

[instance]
http-address = 8080

is equivalent to:

[instance]
http-address = 0.0.0.0:8080

I would expect that

[instance]
http-address = 8080 8081

would be equivalent to:

[instance]
http-address = 0.0.0.0:8080 0.0.0.0:8081

Unfortunately this is not the case. The instance will fail to start in two different ways according to the value of http-fast-listen (on or off).

For fast listen it will break in this line: https://github.com/plone/plone.recipe.zope2instance/blob/d610f9c35459bf73a99ff99e091e28c52deab165/src/plone/recipe/zope2instance/ctl.py#L919 because of:

ValueError: not enough values to unpack (expected 2, got 1)

It should be something like:

host, port = host_port.partition(':')[::2]
host = host or "0.0.0.0"

With fast listen off it will break with:

  File "/home/ale/.buildout/eggs/waitress-1.4.4-py3.8.egg/waitress/wasyncore.py", line 398, in bind
    return self.socket.bind(addr)
OSError: [Errno 99] Cannot assign requested address

I assume a similar simple fix will do the trick.

mauritsvanrees commented 4 years ago

I thought it worked by now, after your fix #147. Is this a different problem? How can we reproduce this?

ale-rt commented 4 years ago

I updated the issue description with more info. I spotted the issue while coding #147 but it is an unrelated problem that was already present. It is a really simple fix to do (will try to provide a patch ASAP) it will probably take less time then explain it.

mauritsvanrees commented 4 years ago

I have merged your fix.

Out of curiosity: what is the use of multiple ports? Are you using this yourself?

I can guess one use:

You could also use two zeoclients, each listening on one port, but that takes more resources (mostly some memory).

ale-rt commented 4 years ago

Actually I am not using it at all!

mauritsvanrees commented 4 years ago

Thanks for fixing it anyway. :-D